On Thu, Dec 18, 2008 at 9:25 AM, Chris Rebert <c...@rebertia.com> wrote:
> As I stated previously, the key rule is:
>
> eval(repr(something)) == something

This rule is only true for basic data types;

For example:

>>> eval(repr(1)) == 1
True
>>> eval(repr([1, 2, 3])) == [1, 2, 3]
True
>>> eval(repr({"a": 1, "b": 2, "c": 3})) == {"a": 1, "b": 2, "c": 3}
True
>>> eval(repr("foo")) == "foo"
True

I guess the key thing here is that the repr
implementation (__repr__) for str, int, float
list and dict return sensible represenations
that Python _can_ evaluate with eval(...)

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

Reply via email to