os.path.normcase rationale?
Ben Finney
ben+python at benfinney.id.au
Fri Sep 24 19:00:01 EDT 2010
Chris Withers <chris at simplistix.co.uk> writes:
> On 21/09/2010 01:02, Steven D'Aprano wrote:
> > What do you mean "the filesystem"?
> >
> > If I look at the available devices on my system now, I see:
> >
> > 2 x FAT-32 filesystems
> > 1 x ext2 filesystem
> > 3 x ext3 filesystems
> > 1 x NTFS filesystem
> > 1 x UDF filesystem
>
> Right, and each of these will know what it thinks a file's "real" name
> is, along with potentially accepting as set of synonyms for them...
They will know internally, but Python has no way of asking them AFAICT,
short of creating a file on the filesystem. That's far outside the
bailiwick of the function in question.
> > Which one is "the" filesystem?
>
> Whichever one you're getting the file from...
Who said anything about “getting the file”? The parameter to the
function is a path, which need not already exist, and which need not
refer to *any* extant filesystem.
> > If you are suggesting that os.path.normcase(filename) should
> > determine which filesystem actually applies to filename at runtime,
> > and hence work out what rules apply, what do you suggest should
> > happen if the given path doesn't actually exist?
>
> I'd suggest an exception be raised.
You really must have an entirely different function in mind. I suggest
you look for it by another name, because ‘os.path.normcase’ already does
something entirely different.
> I didn't say it was an easy problem, but the current normpath is a
> waste of space...
This seems to be code for “it doesn't do what I expected, and now I
don't want to use it”. Surely the solution is clear: don't use it.
--
\ “The industrial system is profoundly dependent on commercial |
`\ television and could not exist in its present form without it.” |
_o__) —John Kenneth Galbraith, _The New Industrial State_, 1967 |
Ben Finney
More information about the Python-list
mailing list