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
In article
dc097623-f377-4c7d-a065-13b58bf1c...@n12g2000yqb.googlegroups.com,
Bruce Eckel lists.ec...@gmail.com wrote:
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:
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
I'm creating a class to encapsulate OS paths, to reduce the visual
noise and typing from the os.path methods. I've got the class and nose
tests below, and everything works except the last test which I've
prefixed with XXX:
def XXXtest_should_work(self):
Produces:
On Mon, Feb 13, 2012 at 2:01 PM, Bruce Eckel lists.ec...@gmail.com wrote:
I'm creating a class to encapsulate OS paths, to reduce the visual
noise and typing from the os.path methods. I've got the class and nose
tests below, and everything works except the last test which I've
prefixed with
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 ...
--