list vs tuple

David Bolen db3l at fitlinxx.com
Wed Mar 28 13:29:34 EST 2001


"Sean 'Shaleh' Perry" <shaleh at valinux.com> writes:

> dir_list is declared as a tuple, which is as close to a const one can find in
> python.

I'm not sure I'd agree - I'd say that dir_list is defined to reference
a tuple, but not that dir_list itself is defined as a tuple.  Python
doesn't associate types with the reference labels but with the objects
themselves.  I don't think that I'd read into that definition anything
more than that dir_list was being initialized to point to an immutable
object - not that dir_list itself might never point to any other object.

It may be as close to a const definition as you can get (at least
textually - an object that was used to retrieve the directory list and
thus could exert control over any ability to change that list would be
symantically closer), but if that was the intent, I think some
comments along with the code would be advisable, albeit only
informational.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list