Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #60359
| References | <l6povp$ndp$1@speranza.aioe.org> <l6pqs8$8b4$1@ger.gmane.org> <5290C30D.5060604@rece.vub.ac.be> <l6r7v6$mhj$1@ger.gmane.org> <5291D536.4010606@rece.vub.ac.be> |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | 2013-11-24 03:45 -0700 |
| Subject | Re: Behavior of staticmethod in Python 3 |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3123.1385289947.18130.python-list@python.org> (permalink) |
On Sun, Nov 24, 2013 at 3:30 AM, Antoon Pardon <antoon.pardon@rece.vub.ac.be> wrote: > Op 23-11-13 22:51, Peter Otten schreef: >> Antoon Pardon wrote: >> >>> Op 23-11-13 10:01, Peter Otten schreef: >>> >>>> >>>> Your script is saying that a staticmethod instance is not a callable >>>> object. It need not be because >>>> >>>> Foo.foo() >>>> >>>> doesn't call the Foo.foo attribute directly, it calls >>>> >>>> Foo.foo.__get__(None, Foo)() >>> >>> I think you are burdening the programmer with implemantation details >>> that don't matter to him. >>> >>> IMO if Foo.foo() is legal then Foo.foo is callable. That the actual call >>> is delegated to Foo.foo.__get__(None, Foo) shouldn't matter. >> >> If you read the original post -- I think in this case the details do matter. >> >> What is your highlevel explanation for > > I don't care about what kind of explanation. I care about a correct answer to > the question whether a particular object is callable (from a programmers point > of view). I'm sure you can give a very comprehensive explanation for why in > this case we get an incorrect answer but that doesn't make the behaviour correct. > > Foo.foo() is legal here. So Foo.foo is callable. So you starting with it needn't > be callable is using "callable" with a different meaning than the natural > interpretation. Al the rest is just an attempt in getting others to accept your > use of "callable" instead of the natural one. > > Foo.foo() being legal and Foo.foo not being callable is IMO a bug in python. No matter > what explanation you have for the behaviour. Your supposition that Foo.foo is not considered callable by Python is false, as Chris already demonstrated, and I don't see where anybody here has stated otherwise. What Peter wrote was that "a staticmethod instance is not a callable object", which is absolutely correct, and these two facts are consistent because Foo.foo is not a staticmethod instance (Foo.__dict__['foo'] on the other hand *is* a staticmethod instance and *is not* callable, and Foo.__dict__['foo']() will correspondingly raise a TypeError).
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Behavior of staticmethod in Python 3 Marco Buttu <marco.buttu@gmail.com> - 2013-11-23 09:28 +0100
Re: Behavior of staticmethod in Python 3 Peter Otten <__peter__@web.de> - 2013-11-23 10:01 +0100
Re: Behavior of staticmethod in Python 3 Marco Buttu <marco.buttu@gmail.com> - 2013-11-23 10:39 +0100
Re: Behavior of staticmethod in Python 3 Peter Otten <__peter__@web.de> - 2013-11-23 16:23 +0100
Re: Behavior of staticmethod in Python 3 Marco Buttu <marco.buttu@gmail.com> - 2013-11-23 10:39 +0100
Re: Behavior of staticmethod in Python 3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-23 13:48 +0000
Re: Behavior of staticmethod in Python 3 Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-11-23 16:00 +0100
Re: Behavior of staticmethod in Python 3 Chris Angelico <rosuav@gmail.com> - 2013-11-24 08:38 +1100
Re: Behavior of staticmethod in Python 3 Peter Otten <__peter__@web.de> - 2013-11-23 22:51 +0100
Re: Behavior of staticmethod in Python 3 Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-11-24 11:30 +0100
Re: Behavior of staticmethod in Python 3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-24 14:18 +0000
Re: Behavior of staticmethod in Python 3 Peter Otten <__peter__@web.de> - 2013-11-24 11:43 +0100
Re: Behavior of staticmethod in Python 3 Ian Kelly <ian.g.kelly@gmail.com> - 2013-11-24 03:45 -0700
Re: Behavior of staticmethod in Python 3 Peter Otten <__peter__@web.de> - 2013-11-24 12:03 +0100
Re: Behavior of staticmethod in Python 3 Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-11-24 16:55 +0100
Re: Behavior of staticmethod in Python 3 Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-11-24 17:08 +0100
csiph-web