Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #80946

Re: import os

References <CAA+hu4U97wO7G00Kdc917XJqJadGCVQEuLJgrO8SPH-NEvjpxQ@mail.gmail.com> <CAPTjJmrit1=EyBbD9tisf=vphmfxOFq8AFkXx7_Fqivqo4a2=g@mail.gmail.com> <CAA+hu4Ve2iy7YwL2yFYW4eZY7U5sHrNZfoFWccJ_HxaAgcY86Q@mail.gmail.com>
Date 2014-11-17 12:34 +1100
Subject Re: import os
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.15935.1416188099.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Mon, Nov 17, 2014 at 12:10 PM, Abdul Abdul <abdul.sw84@gmail.com> wrote:
> Thanks for your reply. Yes, I came across this page, but didn't understand
> what is meant by the operating system dependent functionality. What does
> that mean? Is importing that module that serious?

It's not "serious" as in "using this module can break your code". What
it means is that stuff in the os module might not always be available;
on my Linux box, len(dir(os)) is 326, but on my Windows, it's only
145. (Similar Python versions.) A lot of the os module is available on
every platform you're ever likely to use, but need to be named
differently: for instance, os.curdir is the string representing the
current directory, and os.pathsep is the character that divides
entries in the PATH environment variable. You can assume that there
*will be* some kind of path separator, but you can't know whether
it'll be a semicolon (Windows), a colon (Unix), or something else, so
you call up the os module to find out. In fact, proper use of the os
module can make your code more, not less, cross-platform.

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: import os Chris Angelico <rosuav@gmail.com> - 2014-11-17 12:34 +1100

csiph-web