[Python-Dev] guidance sought: merging port related changes to Library modules

Guido van Rossum guido@python.org
Sat, 12 Jan 2002 15:11:15 -0500


> The particular changes I am looking for guidance on (or BDFL
> pronouncement on, as the case may be) involve os.py and the functionality
> in ntpath.py.
> 
> The approach used in the port as released in binary form was to create a
> module called os2path.py (probably should really be called os2emxpath.py),
> which replicates the functionality of ntpath.py with OS2/EMX specific
> changes.
> 
> Most of the changes have to do with using different path separator
> characters, with a few other changes reflecting slightly different
> behavour under EMX.  EMX promotes the use of '/' as the path separator
> rather than '\', though it works with the latter.  I don't know if Cygwin
> promotes the same convention.
> 
> If I were to merge os2path.py into ntpath.py (which I incline towards
> instinctively) I believe that using references to os.sep and os.altsep
> rather than explicit '\\' and '/' strings would significantly reduce the
> extent of conditionalisation required, but in the process introduce
> significant source changes into ntpath.py (although the logical changes
> would be much less significant).
> 
> If rationalising the use of separator characters (by moving away from
> hard-coded strings) in ntpath.py is unattractive, then I think I'd prefer
> to keep os2path.py (renamed to os2emxpath.py) as is, rather than revert
> to the DOS standard path separators.

The various modules ntpath, posixpath, macpath etc. are not just their
to support their own platform on itself.  They are also there to
support foreign pathname twiddling.  E.g. On Windows I might have a
need to munge posix paths -- I can do that by explicitly importing
posixpath.  Likewise the reverse.

So I think changing ntpath.py to use os.set etc. would be wrong, and
creating a new file os2emxpath.py is the right thing to do -- despite
the endless cloning of the same code. :-(  (Maybe a different way to
share more code between the XXXpath modules could be devised.)

--Guido van Rossum (home page: http://www.python.org/~guido/)