if you want POSIX, import posix, not os

Skip Montanaro skip at mojam.com
Tue Aug 17 10:57:01 EDT 1999

    Fredrik> in fact, the "os" module docs says:

    Fredrik>     This module provides a more portable way of using
    Fredrik>     operating system (OS) dependent functionality than
    Fredrik>     importing an OS dependent built-in module like posix
    Fredrik>     or nt.

I agree with Dan that "posix" should imply "portable".  Outside the Python
world the name "POSIX" has some (not many perhaps, but some) cross-platform
portability connotations.  Perhaps the posix module should be renamed to
"unix".  That way, if you wanted os-specific functionality, you'd import
"unix" or "mac" or "nt" or "dos".

If we had a unix module, each os-dependent module could be split into two
chunks, "posix-whatever" and "non-posix-whatever", say "posixunix" and
"nonposixunix".  On my Linux box, I could import posix to get the portable
subset or import unix to get posix and all the unix-specific stuff.  The
posix module would know to import "posixunix" or "posixnt" or ... as
appropriate.  The unix module would be nothing more than a stub containing

    from posixunix import *
    from nonposixunix import *

All the various "posixwhatever" modules would be required to implement the
same functionality.  If I wanted to add a new function to the unix module it
would have to go into nonposixunix unless I could implement it in all the
other posix* modules.

<nomex state=on>

perhaps-we-can-let-posixdos-be-more-feeble-ly yr,s

Skip Montanaro	| http://www.mojam.com/
skip at mojam.com  | http://www.musi-cal.com/~skip/

More information about the Python-list mailing list