eval(repr(object)) hardly ever works
Steve Holden
steve at holdenweb.com
Wed Sep 13 10:38:03 EDT 2006
More information about the Python-list mailing list
Wed Sep 13 10:38:03 EDT 2006
- Previous message (by thread): eval(repr(object)) hardly ever works
- Next message (by thread): eval(repr(object)) hardly ever works
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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. > That's intentional. Would you have it return the code of all the methods when you take the repr() of a class? regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden
- Previous message (by thread): eval(repr(object)) hardly ever works
- Next message (by thread): eval(repr(object)) hardly ever works
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list