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/2012-June/120487.html below:

[Python-Dev] PEP 362 minor nits

[Python-Dev] PEP 362 minor nitsNick Coghlan ncoghlan at gmail.com
Wed Jun 20 13:54:46 CEST 2012
On Wed, Jun 20, 2012 at 6:30 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> Speaking of non-instance method descriptors, please excuse this silly
> question, I haven't quite understood the implementation well enough to
> answer this question myself. Is there anything needed to make
> signature() work correctly with custom method-like descriptors such as
> this?
>
> http://code.activestate.com/recipes/577030-dualmethod-descriptor

They're odd enough that they would probably need to implement
__signature__ as a property (or custom descriptor) and construct the
appropriate signature on the fly. However, that's only necessary if
you wanted to support passing the descriptor directly to
inspect.signature.

The result of Example.method or Example().method would be an ordinary
function, which would delegate to signature(self.func) by default
(thanks to the use of functools.wraps).

To account for the hidden argument correctly, you would actually want
to set a custom signature that dropped the first parameter.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
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