eval(repr(object)) hardly ever works
Dustan
DustanGroups at gmail.com
Sun Sep 17 09:38:59 EDT 2006
Matthew Wilson wrote:
> I understand that idea of an object's __repr__ method is to return a
> string representation that can then be eval()'d back to life, but it
> seems to me that it doesn't always work.
>
> For example it doesn't work for instances of the object class:
>
> In [478]: eval(repr(object()))
> ------------------------------------------------------------
> File "<string>", line 1
> <object object at 0xf233e8>
> ^
> SyntaxError: invalid syntax
>
> It seems to work for types like integers and dictionaries and lists,
> but not for much else.
>
> Any thoughts?
>
>
> --
> A better way of running series of SAS programs:
> http://overlook.homelinux.net/wilsonwiki/SasAndMakefiles
You have to write the code to return a proper representation.
More information about the Python-list
mailing list