On Fri, Nov 03, 2006 at 05:00:24PM -0700, Levi Pearson wrote: > On Nov 3, 2006, at 4:30 PM, Andrew McNabb wrote: > > >I'm a big fan of Python, but this example made me want to cry. > > > >Grounds for first bullet: > >> value = reduce(lambda x,y: 0 < abs(x-y) <= len(nums) and y or > >> None, [int(item) for item in nums]) > > > >Grounds for second bullet: > >> print '%smatch' % (not value and 'Not a ' or '') > > > > 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. 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. > 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. :) -- Andrew McNabb http://www.mcnabbs.org/andrew/ PGP Fingerprint: 8A17 B57C 6879 1863 DE55 8012 AB4D 6098 8826 6868 /* PLUG: http://plug.org, #utah on irc.freenode.net Unsubscribe: http://plug.org/mailman/options/plug Don't fear the penguin. */
