Conditionals in Python cli with -m oneliner

gvim gvimrc at gmail.com
Sat Apr 9 14:52:15 EDT 2016


Given that this work in a Python 3 repl:

>>> import re
>>> txt = "Some random text"
>>> if re.search(r"\b\w{4}\b", txt): txt
>>> 'Some random text'

.... and this works on the command line, printing all lines in logs.txt:

$ python3 -m oneliner -ne 'line' logs.txt

..... why does this fail:

$ python3 -m oneliner -m re -ne 'if re.search(r"\b\w{4}\b", line): line' 
logs.txt
syntax error in: if re.search(r"\b\w{4}\b", line): line


gvim



More information about the Python-list mailing list