Python as first language (Re: static variables?)

Andrew Koenig ark at research.att.com
Wed Nov 20 22:55:42 EST 2002


Brian> No it doesn't. In C or Java, when you write:

Brian> int a = 5;

Brian> you are, conceptually, saying: stick a 5 in the "a" mailbox.

Brian> In Python, when you write:

Brian> a = 5

Brian> you are, conceptually, saying: 5 is in a mailbox somewhere, make "a"
Brian> know the address of that mailbox. I wouldn't use the mailbox analogy
Brian> with Python though.

The truth is rather more subtle.  For example, you can't write a
Java program to prove your claim, because integers are immutable.
Therefore, there's no way to distinguish between what you say is the
Java treatment and the Python treatment.

In Java, if you replace "int" by a class type, the behavior matches
Python's behavior.  Is that a change or not?  No way to know for sure.


-- 
Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark



More information about the Python-list mailing list