public
Description: Syntactic sugar for creating Python command line scripts by introspecting a function definition
Homepage: http://simonwillison.net/2009/May/28/optfunc/
Clone URL: git://github.com/simonw/optfunc.git
optfunc / demo.py
100755 13 lines (10 sloc) 0.314 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/usr/bin/env python
import optfunc
 
def upper(filename, verbose = False):
    "Usage: %prog <file> [--verbose] - output file content in uppercase"
    s = open(filename).read()
    if verbose:
        print "Processing %s bytes..." % len(s)
    print s.upper()
 
if __name__ == '__main__':
    optfunc.run(upper)