Automatic Type Conversion to String

Bruce Eckel lists.eckel at gmail.com
Wed Feb 15 15:58:43 CET 2012


> Could it be that you missed the fact that strings are immutable? That
> means that you can't change the content of the object once it is
> initialized. In particular, it means that you e.g. have to override
> __new__ instead of __init__, because the content is already fixed when
> the latter is called.
>
> Uli

Yes, that's what I missed, and it explains why I found examples of str
inheritance using __new__. I think this might end up being a puzzle I
poke at for awhile.

Also, I discovered that the attempt to create a "Path" class goes back
to 2006, where it created a lot of discussion and was finally shelved:
http://www.python.org/dev/peps/pep-0355/

A significant part of the problem seems to be that there was no
inheritance from str at the time, so maybe a lot of the issues they
ran into could be solved now.



More information about the Python-list mailing list