Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #12854
| References | <CAOuJsM=vZL1kLgNkgpD6fC=J3APHJTN2RKLGySD9-p0JnxcpzQ@mail.gmail.com> |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | 2011-09-06 15:47 -0600 |
| Subject | Re: import os or import os.path |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.812.1315345714.27778.python-list@python.org> (permalink) |
On Tue, Sep 6, 2011 at 3:25 PM, Jabba Laci <jabba.laci@gmail.com> wrote:
> Hi,
>
> If I want to use the 'os.path' module, it's enought to import 'os':
>
> import os
> if os.path.isfile('/usr/bin/bash'):
> print 'got it'
>
> In other source codes I noticed that people write 'import os.path' in
> this case. Which is better practice?
"import os.path" is better practice. There is no guarantee in general
that the os module will automatically import os.path, and in future
versions or different implementations it might not.
Cheers,
Ian
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: import os or import os.path Ian Kelly <ian.g.kelly@gmail.com> - 2011-09-06 15:47 -0600
csiph-web