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

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!xlned.com!feeder5.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'startup': 0.05; 'alternatives': 0.09; 'executes': 0.09; 'lines.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'tests,': 0.09; 'type,': 0.09; 'used.': 0.09; 'runs': 0.10; 'python': 0.11; 'jan': 0.12; '"python': 0.16; 'index.': 0.16; 'itself,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'regression': 0.16; 'subject:usage': 0.16; 'symbols': 0.16; 'sys.path': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'module': 0.19; 'version.': 0.19; 'starts': 0.20; 'command': 0.22; 'example': 0.22; 'tests': 0.22; 'header:User- Agent:1': 0.23; 'developers': 0.25; 'options': 0.25; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'along': 0.30; 'continues': 0.31; 'doc': 0.31; 'explained': 0.31; 'searches': 0.31; 'option': 0.32; 'another': 0.32; 'quite': 0.32; 'running': 0.33; 'could': 0.34; 'anybody': 0.35; 'test': 0.35; 'but': 0.35; 'really': 0.36; 'indexed': 0.36; 'entry': 0.36; 'hi,': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'received:173': 0.61; 'subject:The': 0.64; 'provide': 0.64; 'different': 0.65; 'received:fios.verizon.net': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: The usage of -m option of python
Date Wed, 27 Mar 2013 13:52:15 -0400
References <CABrM6wkuKu9XSbk4JKpEvX4Dfh=n2UKB4UmaRSTyV45Ezd2mYQ@mail.gmail.com> <ki8khm$23j$1@ger.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host pool-173-75-251-66.phlapa.fios.verizon.net
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130307 Thunderbird/17.0.4
In-Reply-To <ki8khm$23j$1@ger.gmane.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3815.1364406768.2939.python-list@python.org> (permalink)
Lines 38
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1364406768 news.xs4all.nl 6959 [2001:888:2000:d::a6]:59748
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:42021

Show key headers only | 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