list vs tuple

Alex Martelli aleaxit at yahoo.com
Wed Mar 28 14:29:30 EST 2001


"Brian Quinlan" <BrianQ at ActiveState.com> wrote in message
news:mailman.985800580.9546.python-list at python.org...
    [referring to the snippet:
> dir_list = ('/path', '/foo/bar', '/baz/bat/files')
> dir_list shouldn't change and this documents it.
    ]

> I'm not sure that this is a reasonable piece of self documentation since
> dir_list can change. It is the tuple ('/path', '/foo/bar',
'/baz/bat/files')
> that cannot change. Would you say that x = 5 documents that x cannot
change?

It's a common, though sometimes confusing, shorthand, to say
'variablename' meaning "the object (which really, _intrinsically_,
has no particular name, of course) to which the variable named
variablename is right now (temporarily) bound".  It does save
lots of ink^H^H^H bits -- as long as both parties to the given
conversation have enough Python knowledge to grasp that any
variable name can always be re-bound at any time, thus, any
assertions are no doubt meant to refer to the object that variable
is currently bound to.


Alex







More information about the Python-list mailing list