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

Nick Coghlan ncoghlan at gmail.com
Mon Apr 18 03:12:52 EDT 2016

On 18 April 2016 at 05:28, Koos Zevenhoven <k7hoven at gmail.com> wrote:

> So here's oneline.py:
> https://gist.github.com/k7hoven/21c5532ce19b306b08bb4e82cfe5a609
Neat, although you'll want to use importlib.import_module() rather than
calling __import__ directly (the latter won't behave the way you want when
importing submodules, as it returns the top level module for the import
statement to bind in the current namespace, rather than the imported

> I suppose this could be on pypi, and one could do things like
>     oneline.py "random.randint(0,10)"
> or
>     python -m oneline "random.randint(0,10)"
> Any thoughts?

There are certainly plenty of opportunities to make Python easier to invoke
for one-off commands. Another interesting example is pyp:

A completely undocumented hack I put together while playing one day was a
utility to do json -> json transformations via command line pipes:

The challenge with these kinds of things is getting them from "Hey, look at
this cool thing you can do" to "This will materially improve your
day-to-day programming experience". The former can still be fun to work on
as a hobby, but it's the latter that people need to get over the initial
adoption barrier.


> -Koos
> [1] https://pypi.python.org/pypi/np
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/

Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160418/a2f31592/attachment.html>

More information about the Python-ideas mailing list