A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/079730.html below:

Deprecate self

Deprecate self Deprecate selfpiet 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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4