Thomas Wouters wrote: > One of the things brought up at the language summit (and I believe at the VM > summit, although I wasn't there) was the unpredictable behaviour of > callables turning into methods when they're class attributes. [...] > 1. Make staticmethod a callable object directly (it isn't, currently) and > apply it to any Python function that replaces a (in CPython) CFunction. The > change to staticmethod may be a good idea regardless, but the policy of > making other implementations comply to this quirk in CPython seems (to me) > like unnecessary descrimination[*]. I've been bitten by the (to me) surprising fact that staticmethod objects are not directly callable. It's hard to write a method/function inside a class which is callable both when the class is being created, and afterwards, even though naively staticmethod seems like it should do the job. A toy example: class Toy(object): @staticmethod def spam(n): return ' '.join(['spam']*n) lunch = spam(5) + "with a fried egg on top" +1 on making staticmethods callable. I would have found that useful in the past. > 4. Make it an error to have a callable class attribute that isn't a > descriptor (although maybe we only discussed this one in my head.) Do you mean to make one, or both, of these an error? class C: spam = len C.__dict__['ham'] = lambda: None -- Steven
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4