__set_name__ equivalent for instance
Dom Grigonis
dom.grigonis at gmail.com
Thu Nov 16 14:35:31 EST 2023
Thank you.
> On 16 Nov 2023, at 21:30, Dieter Maurer <dieter at handshake.de> wrote:
>
> Dom Grigonis wrote at 2023-11-16 21:11 +0200:
>> ...
>>> On 16 Nov 2023, at 21:00, Dieter Maurer <dieter at handshake.de> wrote:
>>> ...
>>> Methods are not bound during instance creation, they are bound during
>>> access.
>>
>> Good to know. What is the criteria for binding then? Does it check if its type is `vanilla` function? If yes, is there any way to simulate it for arbitrary object?
>
> Attribute access (including method binding) is documented in the
> language reference.
>
> Functions and descriptors accessed via an instance but found in a class (i.e.
> not directly in the instance) are handled specially;
> functions are bound. Other objects are returned as is.
>
> `__getattribute__` can be used to take over control over the attribute
> access.
More information about the Python-list
mailing list