Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Gregory Ewing Newsgroups: comp.lang.python Subject: Re: "from module import data; print(data)" vs "import module; print(module.data)" Date: Fri, 26 Feb 2016 11:20:14 +1300 Lines: 14 Message-ID: References: <535b56b5-f836-4cd6-ae95-33f18004c90b@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net MBdwwGctYOE5mHigywhbtQu/0uSXNFURlizwQbCdN7QN7dIX/s Cancel-Lock: sha1:e2GYcJQigSEmKlr5ypz0QnSrIL4= User-Agent: Mozilla Thunderbird 1.0.5 (Macintosh/20050711) X-Accept-Language: en-us, en In-Reply-To: <535b56b5-f836-4cd6-ae95-33f18004c90b@googlegroups.com> Xref: csiph.com comp.lang.python:103520 sohcahtoa82@gmail.com wrote: > Now, I've noticed people talking about importing os.path. Is there any > reason to use "import os.path" rather than "import os"? Both of them will > still put the "os" module into the global namespace. In the case of os.path it doesn't matter, because the os module imports the appropriate path module automatically. But in general, importing a package won't necessarily import submodules under it, so sometimes you need to import somepackage.somemodule explicitly. -- Greg