Is this a bug?

Alex Martelli aleaxit at yahoo.com
Sat May 12 11:55:07 EDT 2001


"Courageous" <jkraska1 at san.rr.com> wrote in message
news:1u9qfts1jdk8ueh293qcb4fg932p3enlg4 at 4ax.com...
    ...
> >>     If you're trying to build Windows pathnames, note that all
> >>     Windows system calls accept forward slashes too:
> >>
> >>         f = open("/mydir/file.txt") # works fine!
> >
> >Hmmm, I wonder if this needs updating -- it's true for what
> >Python exposes in builtins, module os, etc, but not for what
> >comes in via win32all, I believe... the /-acceptance is in the
> >C runtime libraries (generally) and not in the "system calls"
> >themselves (Windows APIs).
>
> import os
>
> f = os.listdir("/")
> >>> os.listdir("")
> ['jkraska', 'PM-6', 'Utils', 'Progs', 'ffastun.ffa', 'ffastun.ffl',
'Developer',
> 'ffastun0.ffx', 'ffastun.ffo', 'IMAGE.IDX', 'IMAGE.DAT', 'IMAGE.BAK',
'pagefile.sys',
> 'Recycled']
> >>>
>
> I believe that Python treats / as the working volume.

The C runtime library does, but that doesn't affect in the least what
I was saying -- mentioning "Windows system calls" can quite reasonably
make one think of the *Windows APIs*, and those are made available
by win32all -- I think some of them accept forward slashes while others
do not.  (It's not clearly documented in either MSDN or win32all's own
docs... and I don't recall the exact APIs, aka system calls, that refuse
forward slashes and only want backward ones!).

Module os doesn't come into it... it's just about "Windows system
calls" (in the sense of "Windows APIs").


Alex








More information about the Python-list mailing list