Too much code - slicing

John Bokma john at castleamber.com
Wed Sep 22 21:45:55 EDT 2010


Steven D'Aprano <steve-REMOVE-THIS at cybersource.com.au> writes:

For completeness sake:

  code = side == 'l' ? dir[int(num):] : dir[:-1*int(num)]
> code = if side == 'l' then dir[int(num):] else dir[:-1*int(num)]
> code = side == 'l' if dir[int(num):] else dir[:-1*int(num)]
> code = dir[int(num):] if side == 'l' else dir[:-1*int(num)]
>
>
> If you ask me, the *least* hard to read is the last.

For me the (newly added) first one, because it has (for me) less noise.

But I can certainly live with the last one. Or all for that matter. Or
maybe: since the results are already somewhat complex (or noisy) I
probably would use a "normal" if else.

What surprises me is that this is still discussed. It's like argueing
about significant whitespace. :-)

-- 
John Bokma                                                               j3b

Blog: http://johnbokma.com/    Facebook: http://www.facebook.com/j.j.j.bokma
    Freelance Perl & Python Development: http://castleamber.com/



More information about the Python-list mailing list