Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #69204
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'skip:[ 20': 0.04; 'subject:Python': 0.06; 'abuse': 0.07; 'assignment': 0.07; 'subject: [': 0.09; 'subject:language': 0.09; 'cc:addr:python- list': 0.11; 'python': 0.11; '[5]': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'nameerror:': 0.16; 'stumbled': 0.16; 'language': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'tim': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; '"",': 0.31; 'chase': 0.31; 'file': 0.32; '(most': 0.33; 'fri,': 0.33; "i'd": 0.34; 'received:google.com': 0.35; 'recent': 0.39; 'name': 0.63; 'mar': 0.68; 'subject:NOT': 0.84; 'to:none': 0.92 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=5/fnIPjo/KAVtw/Rqq2d8pukc2ipok0tses+NAktm+E=; b=kHg3p46uszNCctU/Z8senN4rluxDw9k2qgwJvtyrYHJEEDEifhCNJWg1fRDRLXf4dM vrkNiiwALWQZ1mhy7GG5Zxms+ubWYNXH0/U0u2qUj4Ck+MoRv0xQ9/GNDos1Kg0a+i77 FHCL5ncyTtLGYua/t1OJhEg+qbe6U9FUIwlvpI45D7IKqoTnq8N6lndU10F4KPtx0xpy eF9h0BUX1C3SS+FHK7EOZbdfTeik5/MpbdFP3TUykg8g8OtPkBj/bg2KKEGItSdZLRaB bv/PG7Pi4Im23q4Bq6qwGaoPsqJZPwEqO3mhFs2gNOabg6J3gs52ErUbRnQHggIwZ8jy rjPw== |
| MIME-Version | 1.0 |
| X-Received | by 10.66.181.70 with SMTP id du6mr2741790pac.23.1395936745657; Thu, 27 Mar 2014 09:12:25 -0700 (PDT) |
| In-Reply-To | <20140327110856.14991bb0@bigbox.christie.dr> |
| References | <20140327110856.14991bb0@bigbox.christie.dr> |
| Date | Fri, 28 Mar 2014 03:12:25 +1100 |
| Subject | Re: Python language hack for C-style programmers [DO NOT USE!] :-) |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.8624.1395936753.18130.python-list@python.org> (permalink) |
| Lines | 23 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1395936753 news.xs4all.nl 2860 [2001:888:2000:d::a6]:57789 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:69204 |
Show key headers only | View raw
On Fri, Mar 28, 2014 at 3:08 AM, Tim Chase
<python.list@tim.thechases.com> wrote:
> So when I stumbled upon this horrific atrocity of language abuse and
> scope leakage, I thought I'd share it.
>
> if [m for m in [regex.match(some_string)] if m]:
> do_something(m)
>
> And presto, assignment in an if-statement.
And presto, it doesn't work in Python 3:
>>> if [m for m in [5] if m]:
print(m)
Traceback (most recent call last):
File "<pyshell#2>", line 2, in <module>
print(m)
NameError: name 'm' is not defined
So definitely don't do it. :)
ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Python language hack for C-style programmers [DO NOT USE!] :-) Chris Angelico <rosuav@gmail.com> - 2014-03-28 03:12 +1100
csiph-web