Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #85277
| Path | csiph.com!usenet.pasdenom.info!news.franciliens.net!fdn.fr!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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; 'else:': 0.03; 'syntax': 0.04; 'explicitly': 0.05; 'assign': 0.07; 'feature.': 0.09; 'snippet': 0.09; 'try:': 0.09; 'python': 0.11; '(),': 0.16; 'blacklist': 0.16; 'blacklists': 0.16; 'entry.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'iterator': 0.16; 'syntaxerror:': 0.16; 'unpack': 0.16; 'wrote:': 0.18; 'feb': 0.22; 'exists': 0.24; 'equivalent': 0.26; 'pass': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'raise': 0.29; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; '"",': 0.31; '>>>>': 0.31; 'obscure': 0.31; 'file': 0.32; 'another': 0.32; 'fri,': 0.33; "can't": 0.35; 'except': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'next': 0.36; 'example,': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'little': 0.38; 'to:addr:python.org': 0.39; 'skip:n 10': 0.64; '2015': 0.84; 'so...': 0.84 |
| 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:to :content-type; bh=sHtUDnI2zlsfWVkxw0T9peBCMTXotPfxbYArlbkvtVo=; b=GigtZ5+C5/NHtuBRkkiHR3RGy1Qm0zl3xAPIdeU5Y3adMlrCHrg/zPEdwG0yePoWQo qeMkh2t9+CsvQYFgPGSvRpAAF8nVsq0J+1vkPt9WUshwYBfSHQtnY7HT3hQnPvzS93L6 KDAyrMqd729gF7SSfC3McIiff0y+qGyWOWCfBWB5kNRgVSoqslThEc/vFeZ+h2a6khSi o/gDxsyRkBOWv0uRgdTXj43YVft/PyFDwgDfTSpcPr8m/ztdB3Rv8ypA7dGaZxjm1joO bARs0fJ4Preqy5YsRtd7MNFktyHS0UU6DNrAwFr412tWeCjrmvmmiW2Hf7ML5zkP9sh9 0tGQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.42.52.200 with SMTP id k8mr10384067icg.26.1423185451553; Thu, 05 Feb 2015 17:17:31 -0800 (PST) |
| In-Reply-To | <CABicbJ+DKbWgR2jGYTCvTLQD6s3TDd7KD6p=xLYD=rxetd71-Q@mail.gmail.com> |
| References | <CAPTjJmpqx1Cmm89Lg6-XL4-xdM+xD6=GHKvWb2zYTe4=11ZPPg@mail.gmail.com> <mailman.18464.1423061056.18130.python-list@python.org> <07f4498c-7917-4315-85d4-73283a830f2d@googlegroups.com> <matlbh$r0s$1@ger.gmane.org> <CAPTjJmp=b2ZA8eqvyf3tqK+0MHqOgS-PAG+ELNNOwuKKPq4FJQ@mail.gmail.com> <mailman.18488.1423127457.18130.python-list@python.org> <54d33aa6$0$13003$c3e8da3$5496439d@news.astraweb.com> <CALwzidnG7gPEe3d3AUMA8B7XZNE48SzeNK+DSdwYKuiGiU7PUg@mail.gmail.com> <CABicbJ+DKbWgR2jGYTCvTLQD6s3TDd7KD6p=xLYD=rxetd71-Q@mail.gmail.com> |
| Date | Fri, 6 Feb 2015 12:17:31 +1100 |
| Subject | Re: meaning of: line, = |
| From | Chris Angelico <rosuav@gmail.com> |
| To | Python <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.18499.1423185454.18130.python-list@python.org> (permalink) |
| Lines | 24 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1423185454 news.xs4all.nl 2921 [2001:888:2000:d::a6]:38437 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:85277 |
Show key headers only | View raw
On Fri, Feb 6, 2015 at 12:12 PM, Devin Jeanpierre
<jeanpierreda@gmail.com> wrote:
> Here's another example, one that still exists in Python 3:
>
>>>> [] = ''
>>>> () = ''
> File "<stdin>", line 1
> SyntaxError: can't assign to ()
>
> The syntax explicitly blacklists (), but forgets to blacklist [].
So... this is actually a really really obscure little feature.
[] = x
# is equivalent to
try: next(iter(x))
except StopIteration: pass
else: raise ValueError("too many values to unpack (expected 0)")
It's a way of asserting that an iterator is exhausted! Perfect code
snippet for your next International Obfuscated Python Code Contest
entry.
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: meaning of: line, = Albert-Jan Roskam <fomcl@yahoo.com> - 2015-02-04 14:38 +0000
Re: meaning of: line, = Rustom Mody <rustompmody@gmail.com> - 2015-02-04 07:09 -0800
Re: meaning of: line, = Peter Otten <__peter__@web.de> - 2015-02-04 18:36 +0100
Re: meaning of: line, = Chris Angelico <rosuav@gmail.com> - 2015-02-05 08:18 +1100
Re: meaning of: line, = Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-02-05 01:10 -0800
Re: meaning of: line, = Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-05 20:40 +1100
Re: meaning of: line, = Ian Kelly <ian.g.kelly@gmail.com> - 2015-02-05 09:08 -0700
Re: meaning of: line, = Rustom Mody <rustompmody@gmail.com> - 2015-02-05 08:45 -0800
Re: meaning of: line, = Skip Montanaro <skip.montanaro@gmail.com> - 2015-02-05 10:56 -0600
Re: meaning of: line, = Tim Chase <python.list@tim.thechases.com> - 2015-02-05 11:00 -0600
Re: meaning of: line, = Rustom Mody <rustompmody@gmail.com> - 2015-02-05 08:59 -0800
Re: meaning of: line, = Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-02-06 05:09 -0800
Re: meaning of: line, = Rustom Mody <rustompmody@gmail.com> - 2015-02-06 05:20 -0800
Re: meaning of: line, = Rustom Mody <rustompmody@gmail.com> - 2015-02-06 06:03 -0800
Re: meaning of: line, = Tim Chase <python.list@tim.thechases.com> - 2015-02-05 10:21 -0600
Re: meaning of: line, = Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-02-05 17:12 -0800
Re: meaning of: line, = Chris Angelico <rosuav@gmail.com> - 2015-02-06 12:17 +1100
Re: meaning of: line, = Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-02-06 17:52 +1300
Re: meaning of: line, = Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-02-06 12:30 +1300
csiph-web