This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Error in 3.3 Tutorial
Type: Stage: resolved
Components: Versions: Python 3.3
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Andesheng, peter.otten
Priority: normal Keywords:

Created on 2014-02-28 11:59 by Andesheng, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg212421 - (view) Author: Gene Anderson (Andesheng) Date: 2014-02-28 11:58
In the tutorial for Python 3.3 the content for 9.3.4 Method Objects seems to have an error.  In the following lines:

xf = x.f
while True:

... it seems to me that based on the x object's method f(), the command should be 


At least it did when I tried to run it without the endless loop.  I'm pretty new at this Python stuff, though, so I could be wrong.
msg212422 - (view) Author: Gene Anderson (Andesheng) Date: 2014-02-28 12:00
I failed to mention that the associated web address for the documentation is:
msg212426 - (view) Author: Peter Otten (peter.otten) * Date: 2014-02-28 13:08
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()

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()

"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
2022-04-11 14:57:59adminsetgithub: 65004
2014-02-28 14:13:41r.david.murraysetstatus: open -> closed
resolution: not a bug
stage: resolved
2014-02-28 13:08:15peter.ottensetnosy: + peter.otten
messages: + msg212426
2014-02-28 12:00:48Andeshengsetmessages: + msg212422
2014-02-28 11:59:00Andeshengcreate