No validation routine for an os.path

Peter Hansen peter at engcorp.com
Tue Aug 17 22:25:14 EDT 2004


Edward Diener wrote:

> Operating systems do have rules for what constitutes a valid file
> specification and/or directory specification. Some even have API functions
> which can be called to directly find out.

True, but with dynamically loadable extensions to the OS, it
seems unlikely that the builtin API for checking filename
validity will necessarily handle a completely new filesystem
that was created after the OS was released...

 > Peter Hansen wrote:
>>In the end, this is somewhat like validating email addresses.  Until
>>you actually try and succeed (or fail) to send the message, you cannot
>>verify whether an address is "valid" for many definitions of valid.
> 
> I do not totally agree, especially as the OS will know whether something is
> valid so it obviously has rules itself. 

Again, the OS might have rules, but they can't always apply
to things that are not really part of the OS, as an add-on
might be.  I'm sure that in most cases the add-on would not
be expanding the set of allowable characters, but it's
certainly not unusual for the set to be narrowed.

 > BTW email addresses actually do have a format which
> can be parsed ( RFC 822 originally ), although again it is complicated.

I was careful to say "for many definitions of valid".  Valid might
be as trivial as checking whether it matches a particular format
(though I think the term "legal" might be more usual there), but
it could also mean "the address actually exists and can receive
mail" in which case you really can't know for sure unless you
try.

In the end, however, I still think the answer to your query is
an unfortunate "sorry, not available".

-Peter



More information about the Python-list mailing list