[Python-ideas] Make Difflib example callable as module __main__

Masklinn masklinn at masklinn.net
Wed Feb 22 23:24:59 CET 2012

On 2012-02-22, at 23:08 , Nick Coghlan wrote:
> On Thu, Feb 23, 2012 at 7:40 AM, Terry Reedy <tjreedy at udel.edu> wrote:
>> If you run difflib directly, it runs difflib._test. which runs a doctest on
>> difflib. Most modules do something similar. Having a real command-line
>> interface in the module itself is unusual.
> That's largely a historical artifact though - prior to -m direct
> execution was a pain, so the only time it really happened was in a
> source checkout during development. (plus I don't believe regrtest
> always had selective test execution, so run the library directly was a
> good way to only run some of the tests).
> If there's useful functionality that can be provided via -m, I'm a fan
> of moving tests out of the way to make room for it (it's also a good
> opportunity to make sure regrtest is covering whatever __main__
> execution tests).
> I think there's also an open tracker issue suggesting the creation of
> a dedicated section in the standard library docs that summarises all
> the modules that offer useful -m functionality.

Last time this popped up, Raymond Hettinger noted undocumented
command-line interfaces to stdlib modules are mostly intentional:

Maybe things have changed since, at the time the sentiment
Raymond expressed was pretty much "not going to happen".

But if you want a list, there's one at

Though things may have changed since and it's for Python 2, it's
a starting point.

More information about the Python-ideas mailing list