Re: The usage of -m option of python

Discussion in 'Python' started by Terry Reedy, Mar 19, 2013.

  1. Terry Reedy

    Terry Reedy Guest

    On 3/18/2013 5:17 PM, Peng Yu wrote:
    > Hi,
    >
    > I don't quite understand how -m option is used. And it is difficult to
    > search for -m in google. Could anybody provide me with an example on
    > how to use this option?


    python -m test
    at a command line runs the regression tests in the test package
    python -m test -v test_difflib
    runs test.test_difflib in verbose mode.

    These are alternatives to
    python <path-to-test> ...
    Python just searches for module itself, same as for import, but executes
    it as main module instead of importing.

    This is really handy for developers running tests, where path-to-test is
    not only a nuisance to type, but different for development builds than
    for installations, and of course, different for each version. Let python
    find the /Lib corresponding to the executable.

    I am not sure if it works for things outside /Lib

    --
    Terry Jan Reedy
     
    Terry Reedy, Mar 19, 2013
    #1
    1. Advertising

  2. In article <>,
    Terry Reedy <> wrote:
    >On 3/18/2013 5:17 PM, Peng Yu wrote:
    >> Hi,
    >>
    >> I don't quite understand how -m option is used. And it is difficult to
    >> search for -m in google. Could anybody provide me with an example on
    >> how to use this option?

    >
    >python -m test
    >at a command line runs the regression tests in the test package
    >python -m test -v test_difflib
    >runs test.test_difflib in verbose mode.


    I get for both :
    "/usr/bin/python: test is a package and cannot be directly executed."

    What gives?

    (Official stable Debian distribution. Python 2.7)

    >--
    >Terry Jan Reedy
    >


    Groetjes Albert
    --
    Albert van der Horst, UTRECHT,THE NETHERLANDS
    Economic growth -- being exponential -- ultimately falters.
    albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
     
    Albert van der Horst, Apr 8, 2013
    #2
    1. Advertising

  3. On 4/8/2013 10:50 AM, Albert van der Horst wrote:
    > In article <>,
    > Terry Reedy <> wrote:
    >> On 3/18/2013 5:17 PM, Peng Yu wrote:
    >>> Hi,
    >>>
    >>> I don't quite understand how -m option is used. And it is difficult to
    >>> search for -m in google. Could anybody provide me with an example on
    >>> how to use this option?

    >>
    >> python -m test
    >> at a command line runs the regression tests in the test package
    >> python -m test -v test_difflib
    >> runs test.test_difflib in verbose mode.

    >
    > I get for both :
    > "/usr/bin/python: test is a package and cannot be directly executed."
    >
    > What gives?
    >
    > (Official stable Debian distribution. Python 2.7)


    For me, 3.3 is default Python.

    Look in the 2.7 doc for 'test' and I believe it will tell you that you
    need to write 'test.regrtest'.

    tjr
     
    Terry Jan Reedy, Apr 8, 2013
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Julien ROUZIERES

    g++ -pg option and -shared option

    Julien ROUZIERES, Dec 21, 2004, in forum: C++
    Replies:
    1
    Views:
    759
    GianGuz
    Dec 21, 2004
  2. Peng Yu

    The usage of -m option of python

    Peng Yu, Mar 18, 2013, in forum: Python
    Replies:
    1
    Views:
    155
    Tom P
    Mar 27, 2013
  3. Chris Angelico

    Re: The usage of -m option of python

    Chris Angelico, Mar 18, 2013, in forum: Python
    Replies:
    0
    Views:
    132
    Chris Angelico
    Mar 18, 2013
  4. Modulok
    Replies:
    0
    Views:
    149
    Modulok
    Mar 18, 2013
  5. Terry Reedy

    Re: The usage of -m option of python

    Terry Reedy, Mar 27, 2013, in forum: Python
    Replies:
    0
    Views:
    138
    Terry Reedy
    Mar 27, 2013
Loading...

Share This Page