Problems trying to override __str__ on path class
no at spam.com
Mon Oct 23 15:28:57 CEST 2006
Peter Otten <__peter__ at web.de> wrote in
news:ehhund$1fi$00$1 at news.t-online.com:
> So my assumption was that you are using a pre-2.1 version of path.
> I suggest that you double-check that by inserting a
> print path.__version__
> into the code showing the odd behaviour before you start looking for
> more exotic causes.
Alas, the print statement says "2.1". So there's a definite platform /
environment difference here, but that isn't it.
> For delegation to work you need (untested)
> class NormPath(object):
> def __div__(self, other):
> return self.__class__(self._path / other)
> # ...
I see. The base class implementation is throwing up its hands at the
unknown type NormPath. One needs to substitute the parameter in every
case where the base class implementation is called. That kind of kills
the attractiveness of the technique for new style classes, unless a way
could be done to do it programatically instead of explicitly for each
method. Of course, if I could get the simple override to work, the need
to do this would disappear.
More information about the Python-list