How to check if a path *could* be a legal path?

Maciej Sobczak no.spam at no.spam.com
Tue Apr 20 06:40:04 EDT 2004


Hi,

I have a string.
This string is to be used as a path for a new file.
I would like to check if this string *could be* a valid file name, 
*before* I try to create the file itself.
In other words, I would like to know whether some string violates the 
underlying OS's policies (or maybe some more restriced policies, but 
portable) considering file paths.

Example:

1.
s = 'C:\file.txt'

the above is potentially a valid path on my system.

2.
s = 'cc:/^- =#jk\kj+.+?! :-)'

the above is rather invalid and I would like to check it somehow before 
I even try to create the file.

Does the Python library contain a functionality that allows to achieve 
this goal?

-- 
Maciej Sobczak : http://www.msobczak.com/
Programming    : http://www.msobczak.com/prog/




More information about the Python-list mailing list