Julian W. suggested that I write a one line Python loop for my command scripts instead of map()
, as in my earlier article. Instead of map(lambda l: expression(l), sys.stdin)
, I could write for l in sys.stdin: expression(l)
. An example trivial command to echo all input lines would be:
python -c "import sys; for line in sys.stdin: print line,"
Problem is that the Python interpreter complains:
File "", line 1 import sys; for line in sys.stdin: print line, ^ SyntaxError: invalid syntax
No comments:
Post a Comment