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 rule though. Some objects (think open files) it would be
impossible (or nearly so) to generate a representation which captured the
state of the object. For others (basic types or containers of them), it's
pretty easy.
Matthew> It seems to work for types like integers and dictionaries and
Matthew> lists, but not for much else.
Matthew> Any thoughts?
Sure, if you want to save and restore objects, pickle or marshal them.
Don't rely on repr().
Skip
--
http://mail.python.org/mailman/listinfo/python-list