variable in Python
exarkun at intarweb.us
Thu Apr 17 15:31:31 CEST 2003
On Thu, Apr 17, 2003 at 12:22:34PM +0200, Salvatore wrote:
> I have a little doubt.
> when you declare x = 3
> does the variable x 'contains' the value 3 (like in Pascal)
> or does it contains an address which points to
> a memory place containing the value 3 ?
Neither. It is a statement (not a declaration) which binds the name "x"
to the integer object associated with the literal 3. The variable does not
contain the object, it refers to it. In this way, it is similar to a
pointer; however, note the difference: there is no explicit way to
"dereference" a Python reference, using it is exactly the same as using the
object it refers to; additionally, there is no concept of a "null"
Hope this helps,
It is practically impossible to teach good programming style to
students that have had prior exposure to BASIC: as potential
programmers they are mentally mutilated beyond hope of
regeneration. -- Dijkstra
up 28 days, 9:02, 5 users, load average: 0.04, 0.03, 0.00
More information about the Python-list