Message212426
No, that's not an error. Given a class MyClass and an instance x of that class
>>> class MyClass:
... def f(self): return 42
...
>>> x = MyClass()
you usually invoke a method like so:
>>> x.f()
42
But it is also possible to break that in two steps
(1) get the "bound method" and store it in a variable for later use:
>>> xf = x.f
(2) call the "bound method" as often as you like:
>>> xf()
42
>>>
"bound method" means that the method "remembers" the instance it is associated with (x in the above example).
Gene, while you are still learning the language please ask on the python-tutor mailing list first before resorting to the bug tracker. |
|
Date |
User |
Action |
Args |
2014-02-28 13:08:15 | peter.otten | set | recipients:
+ peter.otten, Andesheng |
2014-02-28 13:08:15 | peter.otten | set | messageid: <1393592895.08.0.254984748737.issue20805@psf.upfronthosting.co.za> |
2014-02-28 13:08:15 | peter.otten | link | issue20805 messages |
2014-02-28 13:08:14 | peter.otten | create | |
|