Re: [Python-Dev] Writing importers and path hooks

2013年3月29日 13:43:18 -0700

On Fri, Mar 29, 2013 at 3:39 AM, Brett Cannon <[email protected]> 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 | [email protected] | Brisbane, Australia
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to