Python 3K or Python 2.9?

Terry Reedy tjreedy at udel.edu
Thu Sep 13 17:16:14 EDT 2007


"TheFlyingDutchman" <zzbbaadd at aol.com> wrote in message 
news:1189701793.466307.93210 at g4g2000hsf.googlegroups.com...
| Here's a FAQ item where they refer to it as I think Python should have
| done it - a special predefined variable:
|
| http://www.faqs.org/docs/javap/c5/s5.html
|
| "Java provides a special, predefined variable named "this" that you
| can use for such purposes. The variable, this, is used in the source
| code of an instance method to refer to the object that contains the
| method. This intent of the name, this, is to refer to "this object,"
| the one right here that this very method is in. If x is an instance
| variable in the same object, then this.x can be used as a full name
| for that variable. If otherMethod() is an instance method in the same
| object, then this.otherMethod() could be used to call that method.
| Whenever the computer executes an instance method, it automatically
| sets the variable, this, to refer to the object that contains the
| method."

In Python, methods are (functions) contained in (are attributes of) 
classes.  Hence, by the above, 'this' or 'self' would be set to the class 
and not the instance.  So the above would require some rewording for 
Python.

 






More information about the Python-list mailing list