And the reverse? Does os also import os.path?
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Thu Mar 27 15:05:47 EDT 2008
En Thu, 27 Mar 2008 14:22:11 -0300, Bruno Desthuilliers
<bruno.42.desthuilliers at wtf.websiteburo.oops.com> escribió:
> Wilbert Berendsen a écrit :
>> If i do
>>
>>>>> import os
>>>>> os.path.abspath("bla")
>> '/home/wilbert/bla'
>>
>> it seems that just import os also makes available al os.path functions.
>>
>> But is that always true?
>
> Nope. Not all packages expose their sub-packages.
In this case, the idea is to provide an OS-dependent module with a generic
name. The os module imports one of several modules (ntpath, posixpath,
etc.) depending on the current platform, and makes it available under the
generic "path" name so users don't have to worry about that.
(Note that os is a module, not a package; os.path is accessing the "path"
attribute of the os module, not the path module in the os package)
--
Gabriel Genellina
More information about the Python-list
mailing list