import foo vs. python -m foo

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Simon Bierbaum

    import foo vs. python -m foo

    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

  • Hrvoje Niksic

    #2
    Re: import foo vs. python -m foo

    Simon Bierbaum <bierbaum@vierf alt.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__': ...".

    Comment

    • Asun Friere

      #3
      Re: import foo vs. python -m foo

      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?


      Comment

      Working...