Re: import posix

Guido.van.Rossum@cwi.nl
Fri, 05 Aug 1994 16:34:16 +0200

David N. Richards:
> > Hello All - I noticed that module poisixpath.py begins
> > with an 'import posix' statement but I searched through
> > the Lib and can't find any module by that name (posix.py). Yet when
> > I write code that utilizes this everything works fine.
> > Is this built into the python binary?

Steven Majewski:
> Yes.
> As are mac and dos modules on those platforms.

Hmm. The concept of built-in modules seems to be harder to grasp than
I though. An awful lot of newbie questions I get are of the form "I
run demo/test/script foo and it fails with 'module bar not found' but
I can't find where "bar.py" is", where bar is one of the optional
built-in modules. I wonder if the tutorial is unclear in this area?
I suppose I should add this to the FAQ...

> "import os" is the recommended portable way if you want code
> to be os independent. module os will actually be the appropriate
> one. If you REQUIRE posix, then use "import posix" , which will
> raise an error if it fails. ( Unfortunately, for historical
> reasons, I don't think you can't reply on that meaning you
> have the full posix module. The dosmodule is really the posixmodule
> with most of the unix/posix specific functions commented out. )

Well, in more recent DOS binaries, the dos module is actually called
dos, not posix (and it also really is a different file in the sources
now -- though that's perhaps not apparent in 1.0.3 yet, it will
certainly be in 1.0.4 or 1.1). So "import posix" should guarantee
that you actually have the full posix set.

> See previous "newbie" post on how to use os & os.path portably.

Steve, thanks for submitting so much introductory material. It's
really good to have you on the list!

--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>
<URL:http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>