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(
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
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
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.
> >
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
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
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
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
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(
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()))
--
10 matches
Mail list logo