[Python-bugs-list] [Bug #126264] ref/ref3.tex: Remove claim about eval(repr(obj))

noreply@sourceforge.net noreply@sourceforge.net
Tue, 19 Dec 2000 06:11:35 -0800


Bug #126264, was updated on 2000-Dec-18 19:16
Here is a current snapshot of the bug.

Project: Python
Category: Documentation
Status: Closed
Resolution: Fixed
Bug Group: None
Priority: 5
Submitted by: akuchling
Assigned to : gvanrossum
Summary: ref/ref3.tex: Remove claim about eval(repr(obj))

Details: The description of __repr__ in section 3 of the Language Ref
says " This should normally look like a
valid Python expression that can be used to recreate an object with
the same value."  This isn't true, isn't a good idea, 
and often isn't possible anyway.  Rewrite this to emphasize 
that repr() is usually for debugging.



Follow-Ups:

Date: 2000-Dec-19 06:11
By: akuchling

Comment:
That's a bit better, so I won't re-open the bug on you.  (Noticed a small typo and fixed it.)
-------------------------------------------------------

Date: 2000-Dec-18 20:18
By: gvanrossum

Comment:
Checked something in as rev. 1.55.  Let me know what you think.
-------------------------------------------------------

Date: 2000-Dec-18 20:08
By: gvanrossum

Comment:
I disagree with the "isn't a good idea" part.

While it's indeed not a good idea to use eval(repr(x)), it *is* a good idea to make repr(x) look like a syntactically correct expression that would recreate an object with the same value as x, given the appropriate environment (e.g. imported the class or factory function).

I hate non-standard object types whose repr() is indistinguishable from that of a similar standard object -- e.g. UserList makes this mistake, and xrange() used to pretend it was a tuple.

Nevertheless I'll try to think of something to add to the docs.

-------------------------------------------------------

Date: 2000-Dec-18 19:29
By: tim_one

Comment:
Harrumph.  For starters it's true for strings, ints, longs and (as of 1.6) floats, plus lists, tuples and dicts recursively composed of these.  And it's a great idea.  I believe Guido meant what he wrote here:  "should" -- no bug.
-------------------------------------------------------

Date: 2000-Dec-18 19:19
By: akuchling

Comment:
Assigning to GvR, since I assume the LangRef is his responsibility.
I can rewrite the text if the change's intent is approved.
-------------------------------------------------------

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=126264&group_id=5470