|
|
|
|
|
by rraval
4862 days ago
|
|
I know very little of Ruby, but difference 13 states that Ruby has stronger metaprogramming features in that "Python doesn't have define_method, class_eval, and method_missing". Are these really things that can't be implemented with metaclasses and overloading __getattr__? |
|
* define_method simply isn't needed, just set a function as attribute on a class tadaa you've defined a method:
* class_eval I never really understood the use case for, if it's just to add new methods to an existing class, take the previous recipe and annotate the function with the `classmethod` decorator: but there might be more to it I missed.