[path-PEP] Path inherits from basestring again

Steven D'Aprano steve at REMOVETHIScyber.com.au
Sat Jul 23 23:58:08 EDT 2005


On Sat, 23 Jul 2005 17:51:31 -0600, John Roth wrote:

> I also like to know the number of elements, which seems to make
> sense as len(path). Again, the number of characters in the path seems
> to be utterly useless information - at least, I can't imagine a use for
> it.

There are (were?) operating systems that could only deal with a maximum
length for pathnames. If I recall correctly, and I probably don't, Classic
Mac (pre-OS X) was limited to file names of 31 or fewer characters and no
more than 250-odd for the entire pathname. At the very least, some file
manager routines would work and some would not.

If you are printing the pathname, you may care about the length so that
you can truncate it:

longname = "C:\really\really\really\really\really\long\path\name.txt"
if len(longname) > 30:
    # do magic here
    print "C:\really\ ... \path\name.txt"
else:
    print longname



-- 
Steven.




More information about the Python-list mailing list