Re: eval(repr(object)) hardly ever works

2006-09-17 Thread Dustan
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(

Re: eval(repr(object)) hardly ever works

2006-09-16 Thread Tal Einat
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. > [snip] > > Any thoughts? > This is actually an interesting issue when you're working wit

Re: eval(repr(object)) hardly ever works

2006-09-13 Thread [EMAIL PROTECTED]
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. Just to reinforce something Skip mentioned: If you're looking for a way to serialize an ob

Re: eval(repr(object)) hardly ever works

2006-09-13 Thread Donn Cave
In article <[EMAIL PROTECTED]>, "Hardcoded Software" <[EMAIL PROTECTED]> wrote: > 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. > >

Re: eval(repr(object)) hardly ever works

2006-09-13 Thread Fredrik Lundh
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. when in doubt, read the language reference: "If at all possible, this should look l

Re: eval(repr(object)) hardly ever works

2006-09-13 Thread Matthew Wilson
On Wed 13 Sep 2006 10:38:03 AM EDT, Steve Holden wrote: > That's intentional. Would you have it return the code of all the methods > when you take the repr() of a class? I don't think that would be required. Couldn't you return a string with a call to the constructor inside? That's what sets.Se

Re: eval(repr(object)) hardly ever works

2006-09-13 Thread Steve Holden
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(rep

Re: eval(repr(object)) hardly ever works

2006-09-13 Thread skip
Matthew> I understand that idea of an object's __repr__ method is to Matthew> return a string representation that can then be eval()'d back Matthew> to life, but it seems to me that it doesn't always work. No, where it's convenient that property is desirable. It's not a hard-and-fast

Re: eval(repr(object)) hardly ever works

2006-09-13 Thread Hardcoded Software
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(

eval(repr(object)) hardly ever works

2006-09-13 Thread Matthew Wilson
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())) --