[Python-Dev] A wart which should have been repaired in 3.0?
"Martin v. Löwis"
martin at v.loewis.de
Sun Dec 28 21:21:25 CET 2008
> I'm all for breaking backwards compatibility when it allows some genuine
> improvements that would otherwise be impossible, but in this particular
> case a little API bloat seems like the least of the available evils :)
I don't think any change is necessary. os.path.commonprefix works just
fine on path components:
py> p = ["/usr/bin/ls", "/usr/bin/ln"]
py> os.path.commonprefix([f.split('/') for f in p])
['', 'usr', 'bin']
py> p.append("/usr/local/bin/ls")
py> os.path.commonprefix([f.split('/') for f in p])
['', 'usr']
Of course, using it that way would require a library function that
reliably splits a path into components; I think one would have to do
abspath on arbitrary inputs.
Regards,
Martin
More information about the Python-Dev
mailing list