[EMAIL PROTECTED] (Alex Martelli) writes: > > 4. functools enhancements (Haskell-inspired): > > Let f be a function with 2 inputs. Then: > > a) def flip(f): return lambda x,y: f(y,x) > > b) def lsect(x,f): return partial(f,x) > > c) def rsect(f,x): return partial(flip(f), x) > > > > lsect and rsect allow making what Haskell calls "sections". Example: > > # sequence of all squares less than 100 > > from operator import lt > > s100 = takewhile(rsect(lt, 100), (x*x for x in count())) > > Looks like they'd be useful, but I'm not sure about limiting them to > working with 2-argument functions only.
How's from mysterymodule import resect from operator import lt takewhile(rsect(lt, 100), (x*x for x in count())) better than takewhile(lambda x:x<100, (x*x for x in count())) Apart from boiler-plate creation and code-obfuscation purposes? 'as -- http://mail.python.org/mailman/listinfo/python-list