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


Groups > comp.lang.python > #41475 > unrolled thread

Re: The usage of -m option of python

Started byTerry Reedy <tjreedy@udel.edu>
First post2013-03-18 23:03 -0400
Last post2013-04-08 14:47 -0400
Articles 3 — 3 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: The usage of -m option of python Terry Reedy <tjreedy@udel.edu> - 2013-03-18 23:03 -0400
    Re: The usage of -m option of python albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-04-08 14:50 +0000
      Re: The usage of -m option of python Terry Jan Reedy <tjreedy@udel.edu> - 2013-04-08 14:47 -0400

#41475 — Re: The usage of -m option of python

FromTerry Reedy <tjreedy@udel.edu>
Date2013-03-18 23:03 -0400
SubjectRe: The usage of -m option of python
Message-ID<mailman.3484.1363662214.2939.python-list@python.org>
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

[toc] | [next] | [standalone]


#43076

Fromalbert@spenarnc.xs4all.nl (Albert van der Horst)
Date2013-04-08 14:50 +0000
Message-ID<5162d932$0$6060$e4fe514c@dreader36.news.xs4all.nl>
In reply to#41475
In article <mailman.3484.1363662214.2939.python-list@python.org>,
Terry Reedy  <tjreedy@udel.edu> 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

[toc] | [prev] | [next] | [standalone]


#43087

FromTerry Jan Reedy <tjreedy@udel.edu>
Date2013-04-08 14:47 -0400
Message-ID<mailman.299.1365446873.3114.python-list@python.org>
In reply to#43076
On 4/8/2013 10:50 AM, Albert van der Horst wrote:
> In article <mailman.3484.1363662214.2939.python-list@python.org>,
> Terry Reedy  <tjreedy@udel.edu> 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


[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web