[Python-ideas] Add OS-dependent automatic glob support

Stephen J. Turnbull turnbull at sk.tsukuba.ac.jp
Mon Jan 5 19:09:39 CET 2015


Steven D'Aprano writes:

 > The model I am proposing is that of the os and os.path modules: we 
 > import os and it does the right thing for the current platform.

Which is normally "nothing" on POSIX, since the shell does it for
you.  Or, if you're talking about what the shell does for you, while I
suppose there is a basic globbing defined by POSIX, but bash and zsh
go well beyond that, and they behave somewhat differently in corner
cases IIRC.

If the program is going to invoke a globbing function specifically, I
suppose it makes sense to default to the same behavior as on the
current platform, but it's not obvious that that's what the user
wants.  I use bash on Windows; why settle for cmd.exe if you want the
power of the command line?  It could even cause problems (is there a
reliable way to determine what the shell is, let alone whether it
implements globbing or not, on Windows?)

 > In particular, os.path will do the right thing for the current
 > platform, but you can import ntpath, posixpath, genericpath etc. to
 > get behaviour for a specific platform.

But there *is* a RightThang for paths; the OS decides.  Globbing is a
user preference thing.



More information about the Python-ideas mailing list