Deprecate self
piet at cs.uu.nl
piet at cs.uu.nl
Thu Apr 19 06:52:50 EDT 2001
>>>>> Luke <floods at netplus.net> (L) writes:
L> Java's system works just fine. It is assumed when you are writing a
L> class, that a variable is part of that class. It makes more sense. After
L> all why wouldn't you assume first that a variable that is part of a
L> class belongs to that class. If you are dumb and want to put an
L> identical variable in a local scope in a function, for example, then you
L> use this.foo to distinguish. Java is more logical IMHO
But Java has variable declarations, while Python doesn't. So in Java the
compiler can find out where a variable belongs. In Python you can create
instance variables at runtime, so the compiler can't know it is an instance
variable.
E.g.
class A:
def method(self, p):
x = p
return x
a = A()
a.method(1)
a.x=5
a.method(2)
--
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.van.Oostrum at hccnet.nl
More information about the Python-list
mailing list