Path: csiph.com!news.mixmin.net!weretis.net!feeder4.news.weretis.net!storethat.news.telefonica.de!feedme.news.telefonica.de!telefonica.de!fu-berlin.de!uni-berlin.de!not-for-mail From: gvim Newsgroups: comp.lang.python Subject: Conditionals in Python cli with -m oneliner Date: Sat, 09 Apr 2016 19:52:15 +0100 Lines: 19 Message-ID: References: <57094F5F.2080709@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de TWdb5exUyDKdTUkoSpqySQIgfM+d//HQMnBVRBIu35Gg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:Python': 0.05; 'python3': 0.05; 'text"': 0.09; 'python': 0.10; 'syntax': 0.13; '"some': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; '>>>': 0.20; 'txt': 0.22; 'import': 0.24; 'header:User-Agent:1': 0.26; 'command': 0.26; 'error': 0.27; 'random': 0.29; 'received:209.85.215.46': 0.30; 'message-id:@gmail.com': 0.34; 'received:google.com': 0.35; 'lines': 0.36; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'received:209': 0.38; 'why': 0.39; 'does': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'subject:with': 0.40; '.....': 0.76; "'if": 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-transfer-encoding; bh=CAj1WZOrRD59Qx1KkcftMcK9qWzBf2JPHCmdntGV1LY=; b=ezbJ26NwQcbky4cMLopCsOf7RPQeVV6UPKO2amunhM/y0NdHGtaL6ACd3hdBM2J4Zk KxzcDvrex9IEAQvQm23dy486atAO8LIBy7IYpRP45BBVamYPuDS0ToLkh+i/VvvMJE5p 4vHny2A6hmhKl3+AuLKu0fDvoZL7tcdFGcCJ/a7XuXbO+eNBQ1FAp/nRmG1bCs4DQhL5 LFHKgXnQzxFDw3YzkYGJAbRQ5OBJcWExhUykxFvlF0mxUDgnMHZdy+2nz1p+yU4dBIxX CeOHbHrp6M0jT7G/5MbddLdKqgJO8Hvx+IszFcR4TOQ/hG9j005XT/3VB2D67MFZOEIa +yIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:content-transfer-encoding; bh=CAj1WZOrRD59Qx1KkcftMcK9qWzBf2JPHCmdntGV1LY=; b=kFBea4pR6JR2W5VZsiBZ/qGHi/o0LlgL8j31tr+2kYMlJXelSNUc1AxWCcLKxyKNU2 EOS/vK0gZwTrguJ1gHI7osPrBJCrAwxTrGi2x/qWm4h3z4kErpkDyYXJMBrxXyAUvpIX SnLQwtBNjIO3YQ1y0COvM6OlfXK8l2H6o9Gc8Knypu/iyaDKLRv8OTo5zwtjKpHH54gQ w0T7rvjs3fY0Q8nFEZT+CbqB7ff0HljdcequGk8xZ0XNWQ4+wvYyGPOi2S4bb2VPayka S/Di4xmP22pkDXxg2Bb+X+y+RlgEgjlVDxvY5/w9Yp6snm4cudqRetdn7FO8ueF5ZkVV FEsA== X-Gm-Message-State: AD7BkJLGfrejbGVR+pTHerKDr0Im4CowC9bffF1QsCuqmkaLkrryFfr3n2b3ybWgKokb/A== X-Received: by 10.25.153.198 with SMTP id b189mr5654486lfe.94.1460227938034; Sat, 09 Apr 2016 11:52:18 -0700 (PDT) User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <57094F5F.2080709@gmail.com> Xref: csiph.com comp.lang.python:106751 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