PRE-PEP: new Path class; mutability, __hash__, __eq__, __cmp__
Bernhard Herzog
bh at intevation.de
Fri Jan 9 06:41:06 EST 2004
Christoph Becker-Freyseng <webmaster at beyond-thoughts.com> writes:
> So for __eq__ it follows naturaly
> def __eq__(self, other):
> FIXME: isinstance checking
> return (str(self.normalized()) == str(other.normalized()))
> It cares about nonexistent paths, too. (The samefile-solution won't ---
> we might code a special case for it ...)
What exactly does normalized() do? If it's equivalent to
os.path.normpath, then p1 == p2 might be true even though they refer to
different files (on posix, a/../b is not necessarily the same file as
b). OTOH, if it also called os.path.realpath too to take symlinks into
account, __eq__ would depend on the state of the filesystem which is
also bad.
IMO __eq__ should simply compare the strings without any modification.
If you want to compare normalized paths you should have to normalize
them explicitly.
Bernhard
--
Intevation GmbH http://intevation.de/
Sketch http://sketch.sourceforge.net/
Thuban http://thuban.intevation.org/
More information about the Python-list
mailing list