"Gregory Ewing" <greg.ew...@canterbury.ac.nz> a écrit dans le message de
news:e5mgi9fp1b...@mid.individual.net...
Lawrence D’Oliveiro wrote:
Every function is already a descriptor.
Which you can see with a simple experiment:
>>> def f(self):
... print("self =", self)
...
I thought yesterday that every thing was clear. But I have
a doubt now with the following line:
>>> g = f.__get__(17, None)
The signature of __get__ method is __get__ (self, inst, owner) so
once again the first parameter is filled automatically.
Is method __get__ itself a descriptor with an attribute __get__ to perform
the operation ? Hum, it would be endless ...
vars(f.__get__)
TypeError: vars() argument must have __dict__ attribute
no, so how does it work here ?
>>> g
<bound method f of 17>
>>> g()
self = 17
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list