Tuesday, June 4, 2013

Multiple Python one-liners

Notes from MPUG, June 2013: “Python one-liners” talk | Curious Venn

Saw this today, interesting and useful.

The page linked above also has links to other pages with more such Python one-liners, including a discussion on StackOverflow.

Many of the Python one-liners shown, use the "python -m" technique, but that's not all there is to it - some of those also show innovative or non-intuitive uses of that technique.

Two of my favorites from the one-liners shown, are the 'e' module on PyPI :-), and the use of the gzip or zip modules on the command-line as a substitute when you don't have access to a native (un)zip or g(un)zip binary/executable, but do have Python available. "Batteries included" wins here.

You can also run simple Internet servers or clients for HTTP, FTP, POP, SMTP, telnet, etc., using the -m option of Python.

These uses of Python one-liners for Internet purposes reminds me of the REBOL language, in which you can also do such things:


Update: I saw the MPUG Python talk (linked above) via Hacker News, here:


and then wrote this post. Just after writing my post, I visited Planet Python and saw that the MPUG post, by Graeme Cross (curiousvenn.com) was already on the planet.

Anyway, I'm not deleting my post.

Update 2: The HN thread also mentions this other list of one-liners on the Python Wiki:


(some good ones there too), and that list also mentions PyP, a Python tool by Sony ImageWorks to create hjgh-performance image-processing pipelines. I had  blogged about PyP and related Python pipe tools some time ago, and those tools were what gave me the idea to create my pipe_controller project:






- Vasudev Ram

No comments: