import os or import os.path

Joe Riopel goon12 at gmail.com
Tue Sep 6 23:49:34 EDT 2011


On Tue, Sep 6, 2011 at 5:25 PM, Jabba Laci <jabba.laci at 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?

I just followed what the help said:

""
DESCRIPTION
    Instead of importing this module directly, import os and refer to
    this module as os.path.
""



More information about the Python-list mailing list