A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2013-March/125002.html below:

[Python-Dev] Writing importers and path hooks

[Python-Dev] Writing importers and path hooks [Python-Dev] Writing importers and path hooksNick Coghlan ncoghlan at gmail.com
Fri Mar 29 21:41:19 CET 2013
On Fri, Mar 29, 2013 at 3:39 AM, Brett Cannon <brett at python.org> wrote:
> To tell if a module is a package, you should do either ``if mod.__name__ ==
> mod.__package__`` or ``if hasattr(mod, '__path__')``.

The second of those is actually a bit more reliable. As with many
import quirks, the answer to "But why?" is "Because __main__" :P

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4