<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 18 April 2016 at 05:28, Koos Zevenhoven <span dir="ltr"><<a href="mailto:k7hoven@gmail.com" target="_blank">k7hoven@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
So here's oneline.py:<br>
<br>
<a href="https://gist.github.com/k7hoven/21c5532ce19b306b08bb4e82cfe5a609" rel="noreferrer" target="_blank">https://gist.github.com/k7hoven/21c5532ce19b306b08bb4e82cfe5a609</a><br>
<br></blockquote><div><br></div><div>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 submodule)<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
I suppose this could be on pypi, and one could do things like<br>
<br>
    oneline.py "random.randint(0,10)"<br>
<br>
or<br>
<br>
    python -m oneline "random.randint(0,10)"<br>
<br>
Any thoughts?<br></blockquote><div><br></div><div>There are certainly plenty of opportunities to make Python easier to invoke for one-off commands. Another interesting example is pyp: <a href="https://code.google.com/archive/p/pyp/wikis/pyp_manual.wiki">https://code.google.com/archive/p/pyp/wikis/pyp_manual.wiki</a><br></div><div><br></div><div>A completely undocumented hack I put together while playing one day was a utility to do json -> json transformations via command line pipes: <a href="https://bitbucket.org/ncoghlan/misc/src/default/pycall">https://bitbucket.org/ncoghlan/misc/src/default/pycall</a><br><br></div><div>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.<br></div><div><br></div><div>Cheers,<br></div><div>Nick.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
-Koos<br>
<br>
[1] <a href="https://pypi.python.org/pypi/np" rel="noreferrer" target="_blank">https://pypi.python.org/pypi/np</a><br>
<div class=""><div class="h5">_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">Nick Coghlan   |   <a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>   |   Brisbane, Australia</div>
</div></div>