Data Representation?

Kris Caselden google at hanger.snowbird.net
Sat Oct 11 19:40:39 EDT 2003


Say I have some data:

>>> a=[1]
>>> b=[2]
>>> link=[a,b]

The simplest why to write this to a file represents it as

>>> print str(link)
[[1], [2]]

Unfortunately, if this is read back in via execfile(), the whole
dynamic nature of changing 'link' by changing 'a' and 'b' is lost. Is
there any way to write data so that the list name is written instead
of the list's values? Essentially, '[[a], [b]]' instead of '[[1],
[2]]'? Any help most appreciated.




More information about the Python-list mailing list