newbie question
Remco Gerlich
scarblac at pino.selwerd.nl
Thu Feb 8 06:30:35 EST 2001
Denis Laroche <dlaroche at dsuper.net> wrote in comp.lang.python:
> Hello Python enthusiasts,
>
> I just started to learn the language this week.
>
> Could someone tell me how to recreate a list or a dictionary object from
> its string representation obtained with repr().
>
> Thanks in advance for any help.
Often, eval() can restore the value that you got with repr():
>>> eval(repr(["a",3,(1,2,3)]))
["a",3,(1,2,3)]
Of course, this only works if the repr() string has enough information and
was designed for this use (that is, numbers, strings, list etc work, but
once you start using class instances etc it probably won't).
--
Remco Gerlich
More information about the Python-list
mailing list