Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #106751 > unrolled thread

Conditionals in Python cli with -m oneliner

Started bygvim <gvimrc@gmail.com>
First post2016-04-09 19:52 +0100
Last post2016-04-09 19:52 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Conditionals in Python cli with -m oneliner gvim <gvimrc@gmail.com> - 2016-04-09 19:52 +0100

#106751 — Conditionals in Python cli with -m oneliner

Fromgvim <gvimrc@gmail.com>
Date2016-04-09 19:52 +0100
SubjectConditionals in Python cli with -m oneliner
Message-ID<mailman.131.1460227941.2253.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web