Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #42021

Re: The usage of -m option of python

From Terry Reedy <tjreedy@udel.edu>
Subject Re: The usage of -m option of python
Date 2013-03-27 13:52 -0400
References <CABrM6wkuKu9XSbk4JKpEvX4Dfh=n2UKB4UmaRSTyV45Ezd2mYQ@mail.gmail.com> <ki8khm$23j$1@ger.gmane.org>
Newsgroups comp.lang.python
Message-ID <mailman.3815.1364406768.2939.python-list@python.org> (permalink)

Show all headers | View raw


On 3/18/2013 11:03 PM, 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.
>
> 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

It does. All startup options are explained in the section "1.1 Command 
line" of the doc "Python Setup and Usage"

The entry for -m starts "Search sys.path for the named module and 
execute its contents as the __main__ module." and continues another 14 
lines.

Along with other startup options, '-m' is indexed on the Symbols page of 
the index.

-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: The usage of -m option of python Terry Reedy <tjreedy@udel.edu> - 2013-03-27 13:52 -0400

csiph-web