Installing Python in a path that contains a blank

Tim Golden mail at timgolden.me.uk
Tue May 22 08:31:09 EDT 2007


Hamilton, William wrote:

> There's also short filename substitution.  "C:\Documents and Settings\foo"
> can be replaced with "C:\docume~1\foo".  In general, you take the first six
> non-space characters and append "~<digit>" to it.  I've never run into a
> situation where <digit> was anything other than 1, but I'm pretty sure that
> you increment it if you have multiple files/directorys in the same directory
> that have the same first six non-space characters.  This should work on any
> Windows long-filename system where you need 8.3 filenames for backwards
> compatibility.

Rather than trying to second-guess, you can ask
Windows itself to tell you what the short name
is for a given long name:

<code>
import win32api
path_name = "C:\Documents and Settings\goldent"
print win32api.GetShortPathName (path_name)

</code>

(and, yes, there is a corresponding GetLongPathName
with an additional Unicode version GetLongPathNameW)

TJG



More information about the Python-list mailing list