echo Impossible|sed 's/Im/To be /'

May 23, 2008

lpython.py -- one-liner in python

lpython.py Manual Page
Source : download

KaLUG                                   Python Utility Command                          LPYTHON.PY(1)



NAME
         lpython.py -- one-liner in python.

SYNOPSIS
         [ stdout | ] lpythojn.py 'program-text' [ -p ]

DESCRIPTION
         It converts a one-line script to Python code and executes it. Using \n for newline, [space] for indented.
         It will import os, sys, time, re with default setting for much easier usage.

OPTIONS
         -p print python code

EXAMPLES
         cat /etc/passwd | lpython.py 'for i in stdin:\n s=i.split(":")\n if s[0] == "root":\n  for j in range(len(s)):\n   print s[j]'
         cat /etc/passwd | lpython.py 'for i in stdin:\n s=i.split(":")\n if s[0] == "root":\n  for j in range(len(s)):\n   print s[j]' -p
>>>>> PYTHON CODE OUTPUT >>>>>>>>>>>>>>>>>>>>>
from sys import *
from os import *
from time import *
from re import *
for i in stdin:
        s=i.split(":")
        if s[0] == "root":
                for j in range(len(s)):
                        print s[j]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

         cat /etc/passwd | lpython.py 'for i in stdin:\n s=i.split(":"); print s[0],s[5],s[6],'
         cat /etc/passwd | lpython.py 'for i in stdin:\n s=i.split(":"); print s[0],s[5],s[6],' -p

         lpython.py 'for i in range(1,100,5):\n print i'
         lpython.py 'for i in range(1,100,5):\n print i' -p

         lpython.py 'for i in range(1,10):\n for j in range(1,10):\n  print "%dx%d=%d\t" % (j,i,i*j),\n print "\n",'
         lpython.py 'for i in range(1,10):\n for j in range(1,10):\n  print "%dx%d=%d\t" % (j,i,i*j),\n print "\n",' -p

         uname -a | lpython.py 'print stdin.read().split()'
         uname -a | lpython.py 'list=stdin.read().split();print list[2]+"\n",list'

         lpython.py 'a=99;\nfor i in range(50,1000,50):\n print "[%d*%d=%d]" % (a,i,a*i),'

EXAMPLES(2)
         lpython.py 'for i in range(1,10):\n for j in range(1,10):\n  print "%dx%d=%d\t" % (j,i,i*j),\n print "\n",'

lpython.py 'for i in range(1,10):\
 for j in range(1,10):\
  print "%dx%d=%d\t" % (j,i,i*j),\
 print "\n",'

VERSION INFORMATION
         This man page documents lpython.py, version 0.2

AUTHORS
         lloyd at coventive.tv

KaLUG                                   Jul 30 2007                                     LPYTHON.PY(1)