[Python-Dev] why different between staticmethod and classmethod on non-callable object? (original) (raw)
Raymond Hettinger python at rcn.com
Wed Sep 2 01:33:39 CEST 2009
- Previous message: [Python-Dev] why different between staticmethod and classmethod on non-callable object?
- Next message: [Python-Dev] why different between staticmethod and classmethod on non-callable object?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sep 1, 2009, at 2:54 PM, Benjamin Peterson wrote:
2009/9/1 Brett Cannon <brett at python.org>:
On Tue, Sep 1, 2009 at 07:21, Benjamin Peterson<benjamin at python.org> wrote:
2009/8/31 xiaobing jiang <s7v7nislands at gmail.com>:
My idea is: here, the two functions (or maybe classes) should have the same behavior). so is this a bug or something I missing ?
I think they should both not check their arguments in init to allow for duck typing. But what is the point of wrapping something with classmethod or staticmethod that can't be called? It isn't like it is checking explicitly for a function or method, just that it can be called which seems reasonable to me (unless PyCallableCheck() is as off as callable() was). Well, if checking if tpcall is not NULL is as bad as callable, then yes. I don't see any reason to use staticmethod or classmethod with a non-callable, but to be consistent, I would, given the choice between removing code and adding another type check, perfer to remove a type check.
Removing the type check is also my preference.
Raymond -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20090901/3e8e15b4/attachment.htm>
- Previous message: [Python-Dev] why different between staticmethod and classmethod on non-callable object?
- Next message: [Python-Dev] why different between staticmethod and classmethod on non-callable object?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]