Piet van Oostrum <p...@vanoostrum.org> writes: [...] > I could define a auxiliary function like: > > def auxfunc(then, name): > _, mn, dy, _, _, _, wd, _, _ = localtime(then) > return somefunc(mn, day, wd, name) > > and then use > [auxfunc(then, name) for then, name in mylist]
[...] > labels = [somefunc(mn, day, wd, name) > for then, name in mylist > for _, mn, dy, _, _, _, wd, _, _ in [localtime(then)]] > > Python misses a 'where' or 'let'-like construction as in Haskell. "let x = v in e" really is (lambda x:e)(v) In your case: [ (lambda na,ti : somefunc(ti[1],ti[2],ti[6],na))(name,localtime(then)) for then,name in mylist ] Warning: absolutely untested (not even syntax-checked). You may also use *localtime(...) and keep underscores. -- Alain. -- https://mail.python.org/mailman/listinfo/python-list