Simon Brunning wrote:

> On 12/15/05, Steve Holden <[EMAIL PROTECTED]> wrote:
>> Aahz wrote:
>>>     python -c 'import this'
>> 
>> Faster:
>> 
>>    python -m this
> 
> So, there's two ways to do it. ;-)

It's actually a perfect example of an "new" one-obvious-way replacing an
old way (or rather, couple of ways).

In fact, `python -m <module>` is not an exact replacement for `python -c
'import this'`. The -m invocation sets the specified module as the
__main__ module, and so code in:

    if __name__ == '__main__':

will run. The -c import invocation does not set the specified module as
the __main__ module.

The -m semantics are more normally what you want, and so -m has become
the one obvious way to do it (assuming Python 2.4 and up).

Tim Delaney
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to