Rustom Mody <rustompm...@gmail.com> writes: > On Saturday, January 18, 2014 4:49:55 AM UTC+5:30, Piet van Oostrum wrote: [...] > >> Python misses a 'where' or 'let'-like construction as in Haskell. > > +1 > Yes Ive often been bitten by the lack of a 'comprehension-let'
If it used only in a comprehension as in my example you can write instead of 'where vars = expr': for vars in [expr], unnecessarily construction a one element list. If there would be a syntax like: for vars = expr this could be avoided. > > Something like this is possible?? > > > [somefunc(mn,day,wd,name) for (_, mn,dy,_,_,_,wd,_,_), name) in > [localtime(then), name for then, name in mylist]] It works modulo some corrections in the parentheses: [somefunc(mn,day,wd,name) for (_, mn,dy,_,_,_,wd,_,_), name in [(localtime(then), name) for then, name in mylist]] but I find that hardly more elegant. -- Piet van Oostrum <p...@vanoostrum.org> WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list