Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #49559
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed4.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.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'syntax': 0.04; 'true,': 0.05; 'subject:code': 0.07; 'python': 0.11; 'def': 0.12; '10:59': 0.16; 'abusing': 0.16; 'false:': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'lambda:': 0.16; 'rationale': 0.16; 'redundant': 0.16; 'subject:simple': 0.16; 'true:': 0.16; 'wrote:': 0.18; "python's": 0.19; 'bonus': 0.22; 'mon,': 0.24; "i've": 0.25; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'on,': 0.29; 'points': 0.29; 'message-id:@mail.gmail.com': 0.30; 'something': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'yield': 0.36; 'so,': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'simple,': 0.60; 'name:': 0.61; 'name': 0.63; 'jul': 0.74; 'good!': 0.84; '2013': 0.98 |
| 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=KIw4cOlm8tU7YFgEA/abvcfsz2Y1qexPSOKzWQb6UFs=; b=oDtO6QvnWdTwef//3XBptauXCfyiMnuZSQDmSgRTNu7gGHPUunzB4F7ZvXvHMmv+sC tHt8+PVuYvIkOFFXRnTYBTxJYELETup7IMdEZRlBGTD3V4PcNdzZuRAhAgx97DNTbYho JaUKG3L2k8/7e+AO4xpkeTpsMkLfzTmbZO5tUct0h3C5WKTM+l5A93lAhgnwBIngpGN5 1vyBwqDR7mOjZpyCvMCebmfeGezWnSvuiGlTa9EuUgj1TGrFKddT31FZDITtZQlnEhoM pBRDk4/ptfbqJbdUU3vDN336Ic3avoFlLBcfUJfiWhTYrg6d8Bz2XGNi5UtKlckb/mqH H5gQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.58.249.236 with SMTP id yx12mr9632482vec.25.1372684455855; Mon, 01 Jul 2013 06:14:15 -0700 (PDT) |
| In-Reply-To | <b3dcp4Fhl04U2@mid.individual.net> |
| References | <mailman.4021.1372572404.3114.python-list@python.org> <b3dcp4Fhl04U2@mid.individual.net> |
| Date | Mon, 1 Jul 2013 23:14:15 +1000 |
| Subject | Re: Stupid ways to spell simple code |
| From | Chris Angelico <rosuav@gmail.com> |
| 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 <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4069.1372684465.3114.python-list@python.org> (permalink) |
| Lines | 35 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1372684465 news.xs4all.nl 15916 [2001:888:2000:d::a6]:53543 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:49559 |
Show key headers only | View raw
On Mon, Jul 1, 2013 at 10:59 PM, Neil Cerutti <neilc@norwich.edu> wrote:
> On 2013-06-30, Chris Angelico <rosuav@gmail.com> wrote:
>> 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!
>
> I've often thought it was redundant for Python to support 'if'
> when it has dictionaries, cf the rationale for having no
> 'switch'.
>
> valid_name = None
> while not valid_name:
> name = input("Enter your name: ")
> valid_name = {
> True: lambda: print("No name longer than 20 letters."),
> False: lambda: True,
> }[len(name) > 20]()
>
> Much better.
Good! Good! But, waaaah. Waaaah.
def get_name():
while True:
name = input("Enter your name: ")
yield {
True: lambda: print("No name longer than 20 letters."),
False: lambda: name,
}[len(name) > 20]()
name = next(filter(None,get_name()))
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Stupid ways to spell simple code Chris Angelico <rosuav@gmail.com> - 2013-06-30 16:06 +1000
Re: Stupid ways to spell simple code Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-30 07:58 -0700
Re: Stupid ways to spell simple code Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-30 16:08 +0100
Re: Stupid ways to spell simple code Chris Angelico <rosuav@gmail.com> - 2013-07-01 01:20 +1000
Re: Stupid ways to spell simple code Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-30 11:26 -0600
Re: Stupid ways to spell simple code Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-30 17:36 +0000
Re: Stupid ways to spell simple code Roy Smith <roy@panix.com> - 2013-06-30 13:44 -0400
Re: Stupid ways to spell simple code Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-30 22:52 +0100
Re: Stupid ways to spell simple code Neil Cerutti <neilc@norwich.edu> - 2013-07-01 12:59 +0000
Re: Stupid ways to spell simple code Chris Angelico <rosuav@gmail.com> - 2013-07-01 23:14 +1000
Re: Stupid ways to spell simple code Joshua Landau <joshua.landau.ws@gmail.com> - 2013-07-01 17:30 +0100
Re: Stupid ways to spell simple code Marcin Szamotulski <mszamot@gmail.com> - 2013-07-01 20:36 +0100
Re: Stupid ways to spell simple code Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-01 22:09 +0000
Re: Stupid ways to spell simple code 88888 Dihedral <dihedral88888@gmail.com> - 2013-07-01 21:16 -0700
Re: Stupid ways to spell simple code Marcin Szamotulski <mszamot@gmail.com> - 2013-07-02 07:22 +0100
Re: Stupid ways to spell simple code Chris Angelico <rosuav@gmail.com> - 2013-07-02 02:32 +1000
Re: Stupid ways to spell simple code Russel Walker <russ.pobox@gmail.com> - 2013-07-02 00:33 -0700
csiph-web