Am 14.02.2012 00:18, schrieb Bruce Eckel:
I'm willing to subclass str, but when I tried it before it became a
little confusing -- I think mostly because anytime I assigned to self
it seemed like it converted the whole object to a str rather than a
Path. I suspect I don't know the proper idiom for doing this -- any
hints? Thanks ...

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.

Python strings rather behave like Java strings than C++ strings.

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

Reply via email to