tt = a, b = t

Steven Majewski sdm7g at Virginia.EDU
Sun Jan 13 14:10:12 EST 2002


On Sun, 13 Jan 2002, rihad wrote:

> Playing with Python goes on....
>
> tup = 1, 2
> tuptup = a, None = tup
>
> >>> tup
> (1, 2)
> >>> a
> 1
> >>> tuptup
> (1, 2)
>
> How did 2 manage to propagate to tuptup through None?
>

There is nothing special about None -- it's just the name given to
the null object in Python, but like any name, it can be rebound
to another value. Print None after that sequence of commands
above.

  In fact, there can be several 'None's in different modules and
local scopes with different values. There is some code that uses
None to indicate a throw away value, and in a local scope, since
the binding disappears when the function exits, it's not a problem,
except that seeing those examples seems to help propagate this
notion that assignment to None does something different or special.
Use 'none' or 'junk' or '_' or '__' for 'don't care' assignments.
But whatever you use, the value will still get propigated thru
multiple assignment.


-- Steve Majewski






More information about the Python-list mailing list