[Python-ideas] Add __main__ for uuid, random and urandom

Joao S. O. Bueno jsbueno at python.org.br
Fri Apr 1 16:35:25 EDT 2016


On 1 April 2016 at 16:07, Victor Stinner <victor.stinner at gmail.com> wrote:
> Hi,
>
> 2016-04-01 19:41 GMT+02:00 Michel Desmoulin <desmoulinmichel at gmail.com>:
>> I read recently a proposal to allow md5 hashing doing python -m hashlib
>> md5 filename.
>>
>> I think it's a great idea, and that can extend this kind of API to other
>> parts of Python such as:
>>
>> python -m random randint 0 10 => print(random.randin(0, 10))
>
> How many times did you need this feature recently? I don't recall
> having to generate a random number in a range.

Well...actually, really recently (Tuesday), I did
python3 -c "__import__('calendar').calendar(2016)"

And just when this thread started here, I recalled it was possible
to do just
python -m calendar

---------
That is an anecdote related with the features in question, and I
myself can't decide if
it is a point for or against them  :-)
I suppose they'd be "nice to haves" .

But maybe, if instead of sprinkiling 4 - 5 lines of code in "__main__"
files everywhere,
would not make sense to put all of it in a single place?

Maybe shutils itself?
So that python -m shutils.uuid  , python -m shutils.randint, and so on
would each do their thing?


  js
 -><-


More information about the Python-ideas mailing list