By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,517 Members | 1,752 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,517 IT Pros & Developers. It's quick & easy.

import foo vs. python -m foo

P: n/a
Hi all,

what is the difference between saying "import foo" in an interactive
prompt and starting one using "python -m foo"? The -m switch is not
covered in the man page, is it even officially supported? I'm asking
because one of my modules fails on import in the second version but
succeeds in the first.

Thanks, Simon

Oct 28 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Simon Bierbaum <bi******@vierfalt.comwrites:
Hi all,

what is the difference between saying "import foo" in an interactive
prompt and starting one using "python -m foo"? The -m switch is not
covered in the man page, is it even officially supported?
My copy of the man page states:

-m module-name
Searches sys.path for the named module and runs the corresponding
.py file as a script.
I'm asking because one of my modules fails on import in the second
version but succeeds in the first.
It probably contains buggy code inside "if __name__ == '__main__': ...".
Oct 28 '08 #2

P: n/a
On Oct 29, 7:35 am, Hrvoje Niksic <hnik...@xemacs.orgwrote:
It probably contains buggy code inside "if __name__ == '__main__': ...".
Or the code contains a run-time error?
Oct 29 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.