(test) ? a:b

Chris Angelico rosuav at gmail.com
Fri Oct 24 10:45:25 CEST 2014


On Fri, Oct 24, 2014 at 7:38 PM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> Of course one can write hard-to-read code using any idiom by sheer weight of
> complexity or obfuscated naming:
>
> value = [some_function(arg)[23]['key'] or
>          another_function.method((x + y)/(z-x**(y-4)))*
>          some_list[get_index(a)].spam(eggs=False, tomato='yum'),
>          something.do_this(p|q).get(alpha, beta) ^
>          aardvark.bobble("string%s" % carrot.gamma(r&s)*
>          (this & that).fetch(83, 36, when=when or "now")
>          ][cond or flag or foo(42)-1 > 17 or bar(b) < thingy(c) or not d]
>

I can see where your problem is. It is a cardinal error in readability
to have "(x + y)" followed by "z-x". No wonder it's hard to read.

ChrisA



More information about the Python-list mailing list