Postpone evaluation of argument
Righard van Roy
pluijzer at gmail.com
Sat Feb 11 00:01:52 CET 2012
I want to add an item to a list, except if the evaluation of that item
results in an exception.
I could do that like this:
if x > 3:
This looks rather clumbsy though, and it does not work with i.e. list
I was thinking of writing a decorator like this:
def tryAppend(list, item):
This does not work however because the 'item' argument gets evaluated
before the decorator does it's magic.
Is there a way to postpone the evaluation of 'item' till it gets used
inside the decorator. Like it is possible to quote a form in Lisp.
More information about the Python-list