Calling methods without objects?
Stephan Houben
stephanh42 at gmail.com.invalid
Tue Sep 26 15:13:48 EDT 2017
Op 2017-09-25, Stefan Ram schreef <ram at zedat.fu-berlin.de>:
> So, is there some mechanism in Python that can bind a method
> to an object so that the caller does not have to specify the
> object in the call?
>
> If so, how is this mechanism called?
>
Others have already explained the details how functions become bound
methods, but I would just point out that it is an instance of a piece of
very general functionality: the descriptor protocol.
https://docs.python.org/3.6/howto/descriptor.html
With this, you can create your own objects which do some arbitrary
special thing when accesses on an instance.
Stephan
More information about the Python-list
mailing list