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/2013-July/127191.html below:

[Python-Dev] lament for the demise of unbound methods

[Python-Dev] lament for the demise of unbound methodsBenjamin Peterson benjamin at python.org
Thu Jul 4 21:50:09 CEST 2013
2013/7/4 Eric Snow <ericsnowcurrently at gmail.com>:
>
> On Thu, Jul 4, 2013 at 5:21 AM, Chris Withers <chris at simplistix.co.uk>
> wrote:
>>
>> Hi All,
>>
>> In Python 2, I can figure out whether I have a method or a function, and,
>> more importantly, for an unbound method, I can figure out what class the
>> method belongs to:
>>
>> >>> class MyClass(object):
>> ...   def method(self): pass
>> ...
>> >>> MyClass.method
>> <unbound method MyClass.method>
>> >>> MyClass.method.im_class
>> <class '__main__.MyClass'>
>>
>> There doesn't appear to be any way in Python 3 to do this, which is a
>> little surprising and frustrating...
>>
>> What am I missing here?
>
>
> You could always monkeypatch builtins.__build_class__ to add an attribute to
> every "unbound method" pointing to the class.

I would not reccomend that. __build_class__ is very internal and it's
contract may change between versions.



--
Regards,
Benjamin
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