Stefan Behnel <stefan...@behnel.de> writes: > karmaguedon, 28.10.2010 18:46: >> On 27 oct, 10:27, Arnaud Delobelle wrote: >>> Chris Rebert writes: >>>> This is stunt coding / code golf; no one should actually write >>>> factorial like that. >>> >>> True. It's far too verbose. I'd go for something like: >>> >>> f=lambda n:n<=0 or n*f(~-n) >>> >>> I've saved a few precious keystrokes and used the very handy ~- >>> idiom! >> >> I didn't know the idiom, nice tip. > > Not really. Given that many people won't know it, most readers will > have a hard time deciphering the above code, so it's best not to do > this. > > Stefan
My reply was obviously tongue in cheek, triggered by Chris Rebert's "code golf" remark. using ~-n instead of n-1 if obfuscatory and doesn't even save keystrokes! (Although it could in other situations, e.g 2*(n-1) can be written 2*~-n, saving two brackets.) -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list