Problems trying to override __str__ on path class
no at spam.com
Mon Oct 23 04:33:49 CEST 2006
Peter Otten <__peter__ at web.de> wrote in
news:ehggfk$60i$00$1 at news.t-online.com:
> I get
> np: "overridden __str__: c:/mbk/test"
> str(np): "overridden __str__: c:/mbk/test"
> overridden __str__: overridden __str__: c:/mbk/test/appendtest
Hmmm. I guess you're not running under windows, since normpath()
converts / to \ on windows. I wonder if that's part of the problem.
> Are you using the latest version of the path module?
My path.py says it's 2.1, which is the latest according to the site.
> implied a Path() call in the __div__() operator which would explain at
> least the output you get for
> print np / 'appendtest'
You've lost me here. What do you mean about "implied a Path() call"?
Here is the definition of __div__ from path.py:
# The / operator joins paths.
def __div__(self, rel):
""" fp.__div__(rel) == fp / rel == fp.joinpath(rel)
Join two path components, adding a separator character if
return self.__class__(os.path.join(self, rel))
I still don't understand the TypeError in the delegation case.
More information about the Python-list