[Python-Dev] os.path function for “get the real filename” (was: os.path.normcase rationale?)
Guido van Rossum
guido at python.org
Sat Sep 25 01:24:28 CEST 2010
I think searching a case-sensitive filename for a case-insensitive
match should not be offered as part of os.path. Apps that really want
to do things like """There is no file named "README", do you want to
use "Readme" instead?""" can write their own inefficient code, thank
On Fri, Sep 24, 2010 at 4:15 PM, Ben Finney <ben+python at benfinney.id.au> wrote:
> 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
> Python-Dev mailing list
> Python-Dev at python.org
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org
--Guido van Rossum (python.org/~guido)
More information about the Python-Dev