$10K coding deathmatch
levi at cold.org
Mon Nov 6 14:18:04 MST 2006
On Nov 6, 2006, at 1:48 PM, Andrew McNabb wrote:
>> Are you objecting to the use of logical operators as conditionals?
>> The list comprehension? The anonymous function? The functional
>> style in general?
> People should be shot for using logical operators as conditionals.
I agree, they should not be used as such if there's an alternative.
Pre-1.5 python apparently doesn't supply a conditional expression,
> Also, you shouldn't inline a function unless it's short and concise.
> It's really not hard to put a def statement just before the reduce.
That looked like a pretty short function to me.
>> The program looks pretty clear to me, aside from using logical
>> operators instead of conditionals, but AFAIK there's no explicit
>> conditional expression in Python so one doesn't have much choice when
>> attempting to program in functional style.
> Have you ever heard of "if" and "else"? I usually call them
> conditionals. :)
Yes, but there is a difference between conditional statements and
conditional expressions. One fits in the 'statements' parts of the
grammar while the other fits in the 'expressions' parts of the grammar.
The program was certainly not going to win any beauty contests, but I
didn't think it was unclear aside from using boolean operators as
conditionals and relying on a type error for an early exit. I'm
surprised you didn't mention that one yourself, since I find it by
far the worst offense. And none of it really warrants shooting,
unless the Python Police are truly as draconian as you suggest. :)
More information about the PLUG