On 05/09/11 22:38, Jon Redgrave wrote: > It seems unreasonably hard to write simple one-line unix command line > filters in python: > > eg: ls | python -c "<something> print x.upper()" > > to get at sys.stdin or similar needs an import, which makes a > subsequent for-loop illegal. > python -c "import sys; for x in sys.stdin(): print x" <<- SyntaxError > > Am I missing something obvious?
ls | python -c "for line in __import__('sys').stdin: print (line.upper())" -- http://mail.python.org/mailman/listinfo/python-list