PyOne - Python One-liner helper
Author: Yusuke Shinyama 
small modifications by Goetz Pfeiffer 

For Python 1.5 or higher

usage: pyone [-d] [-i modules] [-f modules] script args ...

Description:
  This is a helper script for quick and dirty one-liner in Python.
  It converts a given script to properly indented Python code
  and executes it. If a single expression is given it simply
  eval it and displaysthe the retuen value.

Options:
  -h         : this help
  -d         : debug mode. (dump the expanded code and exit)
  -i modules : add 'import modules' at the beginning of the script.
  -f modules : add 'from modules import *' for each module.

Syntax:
  ;          : inserts a newline and make proper indentation.
               ex. "A; B; C" is expanded as

                 A
                 B
                 C

  { ... }    : makes the inner part indented.
               ex. "A { B; C }" is expanded as

                 A:
                    B
                    C

  EL{ ... }  : wraps the inner part as a loop executed for each line
               of files specified by the command line (or stdin).
               The following variables are available inside.

                 L:   current line number.
                 S:   current raw text, including "\n".
                 s:   stripped text line.
                 F[]: splited fields with DELIM.
                 I[]: integer value obtained from each field if any.

               Precisely, it inserts the folloing code:

                 L = -1
                 while 1:
                   S = getnextline(args)
                   if not S: break
                   L = L + 1
                   s = string.strip(S)
                   F = string.split(s, DELIM)
                   I = map(toint, F)
                   (... your code here ...)

Special variables:
  DELIM : field separator used in EL { } loop.
  args  : command line arguments.

Examples:
  $ pyone 2+3*5.6
  $ pyone -f cdb 'd=init("hoge.cdb");EL{if d.get(F[0]): print s}' testfiles
  $ wget -q -O- http://slashdot.org/ | \
    pyone -f sgmllib 't=[""];class p(SGMLParser){def handle_data(s,x)\
                      {global t;t[-1]+=x;} def start_td(s,x){t.append("")} \
                      def end_td(s){print t[-1];del(t[-1])}} \
                      x=p(); EL{x.feed(s)}'