Preventing 'bad' filenames from raising errors in os.path

John Nagle nagle at animats.com
Sat May 3 12:38:48 EDT 2008


python at bdurham.com wrote:
> Bad file names, i.e. filenames the OS considers illegal, will cause
> functions in the os.path module to raise an error.
> 
> Example:
> 
> import os.path
> print os.path.getsize( 'c:/pytest/*.py' )

    The issue, I think, is there's no function that checks
syntax of a path name without checking with the underlying OS
to see if the file exists.

    If, say, you're writing a GUI tool for setting up some configuration,
you'd want to do input validation on fields without actually
accessing the files.

				John Nagle



More information about the Python-list mailing list