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/068195.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
Sat Aug 12 08:38:49 CEST 2006
Martin v. Löwis wrote:
> Nick Coghlan schrieb:
>> It would be nice if there was a similar mechanism for normal instance methods 
>> as well:
>>
>>    method = function(some_callable)
>>
> 
> If you know you have to put something around it, what's wrong with writing
> 
>   method = lambda *args:some_callable(*args)
> 
> If that happens often enough, you can write
> 
> def function(f):
>   return lambda *args:f(*args)

Both of those are inferior to defining a new method with the right name and 
arguments and a docstring directing readers to the relevant function (which is 
what I would do for this situation at the moment).

The idea of the builtin would be to let introspection tools know that the 
documentation of the existing callable applies to the method as well, so that 
things like help(x.method) could retrieve something more useful than:

 >>> help(C().method)
Help on method method in module __main__:

method(*args, **kwds) method of __main__.C instance

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