Too much code - slicing

Seebs usenet-nospam at seebs.net
Sat Sep 18 18:56:51 EDT 2010


On 2010-09-18, Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> wrote:
> On Fri, 17 Sep 2010 16:01:54 -0400, Andreas Waldenburger wrote:
>> On Thu, 16 Sep 2010 16:20:33 -0400 AK <andrei.avk at gmail.com> wrote:
>>> I also like this construct that works, I think, since 2.6:

>>> code = dir[int(num):] if side == 'l' else dir[:-1*int(num)]

>> I wonder when this construct will finally start to look good.

> It looks good to me. It follows a common English idiom:

> "What are you doing tonight?"
> "I'll be going to the movies, if I finish work early, otherwise I'll stay 
> home and watch a DVD."

I hate that idiom in English, too.  If you're going to give me a forking
conditional, I want to know about it early.

Basically, I can handle
	do x if y
pretty well, but
	do x if y else z
always breaks my parser.

So in English, I might say "I'll go to the store if I have time", but
I'd rarely use "I'll go to the store if I have time, otherwise I'll send
the house elf"; instead, I'd say "If I have time, I'll go to the store,
otherwise I'll send the house elf."

-s
-- 
Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nospam at seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.



More information about the Python-list mailing list