Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'syntax': 0.04; 'inspired': 0.05; 'subject:code': 0.07; 'raises': 0.09; 'def': 0.12; 'abusing': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'nick': 0.16; 'stupid,': 0.16; 'subject:simple': 0.16; 'wrote:': 0.18; 'discussion': 0.18; 'bit': 0.19; "python's": 0.19; 'bonus': 0.22; 'function': 0.29; 'on,': 0.29; 'points': 0.29; 'raise': 0.29; 'message-id:@mail.gmail.com': 0.30; '>>>>': 0.31; 'could': 0.34; 'something': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'so,': 0.37; 'easily': 0.37; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'simple,': 0.60; 're:': 0.63; 'more': 0.64; '30,': 0.65; 'insane': 0.93; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=H+sT4dH4WBh75+Q+r9jY2YV+lGsYJZWDPCIMza60B8w=; b=tpPfPHFHS54tmL5NDE+5t4gkVMS+hDZJaNcWQSg6yfi/c0EdR2iacxxXOZ2ix6pAbi 4FdPOKNzIIJ1XMsknJqwQe6tkUpErSWszJdLFUXhqvljOCkDLNbn3jncOlpBBGt+SxU4 iu6mNSJtws2qXCTOJlauKr7sPf39AOpHJ9TNf7P0P8DxzkDV0n2Q7yF08HqysCPGNwB4 6P0CUvwjvWacpNDDXPPbNIPAXtcbbV15aGlt1Qkmc0EM7FhaAP5NeiDMWHfrjPFqakkZ Jlvl3HZuyrHt2ETT6Mf1G09W1+z/AGu5N4gWupRub8y7cgD/g9tgfP68BTQ7c+bMnU5H RJ6A== MIME-Version: 1.0 X-Received: by 10.221.4.4 with SMTP id oa4mr7870428vcb.70.1372572395314; Sat, 29 Jun 2013 23:06:35 -0700 (PDT) Date: Sun, 30 Jun 2013 16:06:35 +1000 Subject: Stupid ways to spell simple code From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1372572404 news.xs4all.nl 15921 [2001:888:2000:d::a6]:33333 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:49476 There's a bit of a discussion on python-ideas that includes a function that raises StopIteration. It inspired me to do something stupid, just to see how easily I could do it... On Sun, Jun 30, 2013 at 3:45 PM, Nick Coghlan wrote: Re: [Python-ideas] "Iteration stopping" syntax >>>> def stop(): > ... raise StopIteration Here's a much more insane way to spell that: stop = (lambda: 0 and (yield 1))().__next__ So, here's a challenge: Come up with something really simple, and write an insanely complicated - yet perfectly valid - way to achieve the same thing. Bonus points for horribly abusing Python's clean syntax in the process. Go on, do your worst! ChrisA