if you want POSIX, import posix, not os
connolly at w3.org
Tue Aug 17 06:58:43 CEST 1999
I have thought this was broken for years, but I just read
it again tonight, and I'm not going to pass over it in silence this
"Do not import this module directly. Instead, import the module os,
which provides a portable version of this interface."
I think this is terrible advice.
The os module is *not* portable:
Return the current process group id. Availability: Unix. "
on my NT box:
>>> import os
Traceback (innermost last):
File "<interactive input>", line 0, in ?
What's portable about that?
A portable interface is one where I can expect consistent behaviour
of named objects across platforms, no?
All I know about a python program that imports os is that
it might work on some platforms and not on others. That's
the exact *opposite* of portable, no?
The IEEE POSIX spec is widely implemented and understood.
When a program expects behaviour as specified in the POSIX
specs, it should say
no? If an implementation on WinNT provides posix semantics,
then it may supply a module by that name that works as
expected. Otherwise, I want an early ImportError, not
later AttributeErrors, or worse: silent failures to
behave as specified.
It would have made sense for python to define a really portable os
module, i.e. the least common denominator of the platforms it
runs on. But that's not what we've got.
I hope the os module will be deprecated in future releases.
Dan Connolly, W3C
More information about the Python-list