[Python-Dev] Making staticmethod objects callable?
Steven Bethard
steven.bethard at gmail.com
Wed Mar 1 16:50:21 CET 2006
More information about the Python-Dev mailing list
Wed Mar 1 16:50:21 CET 2006
- Previous message: [Python-Dev] Making staticmethod objects callable?
- Next message: [Python-Dev] Making staticmethod objects callable?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 3/1/06, Nicolas Fleury <nidoizo at yahoo.com> wrote: > Basically, should staticmethods be made callable so that the following > would not raise an exception: > > class A: > @staticmethod > def foo(): pass > bar = foo() > > There's workarounds, but it's really just about usability. staticmethod > could still return a descriptor, but additionnally callable. Is there > something I'm missing? Is it error-prone in any way? My only (mild) concern is that if staticmethod is going to get a __call__, I think classmethod should probably get one too. Inside a class this doesn't make much sense: class A(object): @classmethod def foo(cls): pass bar = foo(None) # ?? But I guess outside of a class maybe it's okay: @classmethod def foo(cls): pass class A(object): pass foo(A) Anyway, my feeling was that running into this behavior (that staticmethod is not callable) is a good oportunity to explain how descriptors work. And once you start playing around with staticmethod and classmethod, you're going to need to learn that pretty soon anyway. Hiding it a little bit longer with a __call__ method on staticmethod isn't going to help much in the long run. So I guess I'm -0 if classmethod gets a __call__ too. STeVe -- Grammar am for people who can't think for myself. --- Bucky Katt, Get Fuzzy
- Previous message: [Python-Dev] Making staticmethod objects callable?
- Next message: [Python-Dev] Making staticmethod objects callable?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list