[Tutor] using lists as values for key in dictionary?
wesley chun
wescpy at gmail.com
Wed Oct 15 09:22:10 CEST 2008
>> so if you turn your list into a tuple (I can never remember, is that a
>> cast or a coercion?)
>
>> lX = tuple(lX)
>
> To answer my own question: neither, but it's closer (in spirit) to a cast.
you're keeping everyone is suspense! :-) you are creating a brand new
tuple by copying out the references to the objects in the list. then
you assign that tuple to the variable that previously referenced your
original list.
NOTE: the original object remained as a list with no modifications,
but was probably marked for deallocation when you dropped your
references to it unless there were other references to it.
cheers,
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
http://corepython.com
"Python Web Development with Django", Addison Wesley, (c) 2008
http://withdjango.com
wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
More information about the Tutor
mailing list