Slaunger wrote:
On 6 Aug., 21:36, Terry Reedy <[EMAIL PROTECTED]> wrote:

OK, the situation is more complicated than that then. In the case here
though,
the attributes would always be sinmple bulit-in types, where
eval(repr(x))==x
or, where the attribute is a user-defined equal-by-value class, that I
have
control over.

I think most would agree that a more accurate and informative representation is better than a general representation like Pythons default. For instance,
>>> a=range(2,10,2) # 3.0
>>> a
range(2, 10, 2)

is nicer than <class 'range' object at ######>.

So when the initializers for instances are all 'nice' (as for range), go for it (as in 'Age(10)'). And test it as you are by eval'ing the rep. Just accept that the eval will only work in contexts with the class name bound to the class. For built-in like range, it always is, by default -- unless masked by another assignment!

Terry Jan Reedy


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to