[Python-Dev] os.path function for “get the real filename” (was: os.path.normcase rationale?)
Ben Finney
ben+python at benfinney.id.au
Sat Sep 25 01:15:25 CEST 2010
Greg Ewing <greg.ewing at canterbury.ac.nz> writes:
> Maybe we could use a heuristic such as:
Your heuristics seem to assume there will only ever be a maximum of one
match, which is false. I present the following example:
$ ls foo/
bAr.dat BaR.dat bar.DAT
> 1) Search the directory for an exact match to the name given,
> return it if found.
And what if there are also matches for a case-insensitive search? e.g.
searching for ‘foo/bar.DAT’ in the above example.
> 2) Look for a match ignoring case. If one is found, test it to
> see if it refers to the same file as the given path, and if so
> return it.
And what if several matches are found? e.g. searching for ‘foo/BAR.DAT’
in the above example.
> 3) Otherwise, raise an exception.
It seems to me this whole thing should be hashed out on ‘python-ideas’.
--
\ “In case you haven't noticed, [the USA] are now almost as |
`\ feared and hated all over the world as the Nazis were.” —Kurt |
_o__) Vonnegut, 2004 |
Ben Finney
More information about the Python-Dev
mailing list