A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-August/068220.html below:

[Python-Dev] 2.6 idea: a 'function' builtin to parallel classmethod and staticmethod

[Python-Dev] 2.6 idea: a 'function' builtin to parallel classmethod and staticmethod [Python-Dev] 2.6 idea: a 'function' builtin to parallel classmethod and staticmethodNick Coghlan ncoghlan at gmail.com
Mon Aug 14 11:10:20 CEST 2006
Guido van Rossum wrote:
> It ought to be called @instancemethod for a better analogy.

That's actually what I was originally going to suggest.

And then I changed my mind after wondering how I would answer the question 
"Why don't I need to decorate functions with @instancemethod in order to use 
them as instance methods, but I need to decorate them with @classmethod and 
@staticmethod to use them as class and static methods?".

However, now that I've thought about it some more, the explanation would 
simply be that functions behave like instancemethod instances by default, 
while other callables typically behave like staticmethod instances.

So instancemethod(f) would return the passed in object for an actual function, 
and a wrapper with an appropriate __get__ method for anything else (stealing 
__doc__ etc from the original callable).

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org
More information about the Python-Dev mailing list

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