|
1
|
I was looking for a way to have a method that when called on a class would get the class as its first argument, and when called on an instance would get that instance. Here is a nice way to do this (curry implementation thanks to http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/222061)
Another way to do this would be to have a __hidden_method, have public_method = classmethod(__hidden_method) in the class, and set public_method = __hidden_method in __init__. This solution isn't very clean though, while this decorator is reusable :-) |
Add a comment
Sign in to comment
Download
Copy to clipboard
