
April 29, 2009
6:25 a.m.
Mathias Panzenböck wrote:
Pascal Chambon wrote:
Then just call* delayedNested(partial(A,...arguments...), partial(B, ...arguments...))*/ /to have what you want.
It would be much shorter and more readable to manually nest the with statements.
You could improve the look a little by changing the input excepted. Say: with delaynested( [A, B], [(A_arg1, A_arg2), B_args]): do_stuff() A realistic example: with delaynested([getlock, open], [None, ("file.txt",)]): #Notice that the comma is important! do_stuff() Is that so bad? I think it looks OK. That said, it would be nice if there were a better way to do partial functions than either lambda or functools.partial. -- Carl