[Python-ideas] site.py uses os.sep to determine platform

Nick Coghlan ncoghlan at gmail.com
Sun Feb 12 16:47:41 EST 2017


On 12 February 2017 at 16:05, Steve Dower <steve.dower at python.org> wrote:
> It depends on what the code beneath the if is doing. "Windows" may be a
> shorthand for "uses backslash", in which case the check is correct.

In this case, it's to decide whether the default way of entering EOF
at the terminal is by pressing Ctrl-D (POSIX-style) or Ctrl-Z+Enter
(Windows-style).

There's another case in site.py where "os.sep='/'" is used to decide
whether or not the site-packages path should be qualified with the
python version.

In the cases where it is used, the separator is likely to give you the
right answer under things like Cygwin, MinGW and WSL (all of which
should use "/" for the default path separator and Ctrl-D to enter EOF
even though you're actually running on a Windows machine), but I
wouldn't place any bets on it being easy to replicate the separator
setting (and os.path module selection) logic that figures that out in
the first place.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-ideas mailing list