statement level resumable exception

Arnaud Delobelle arnodel at gmail.com
Fri Jan 21 02:41:02 EST 2011


ilejn <ilja.golshtein at gmail.com> writes:

> Arnaud,
>
> these lists are not generated.
>
> Actually these lists are a sort of interpreted programs and contain
> some application logic.
>
> Here is an example
>         [
>         [PUSH, [get_modified_interface, req]],
>         [TIMEOUT, 3],
>         [PULL, [out_interface, '']],
>         [PULL, [err_interface, '']],
>         [PULL, [out_mined_interface, req]],
>         ]
>
> If any interface name is unknown the list must not be invoked (in
> other words, f function
> call with this list must be somehow bypassed).
>
> Thanks.

You could still use the same idea and delay evaluation of the lists. E.g.

prg1 = """[
    [PUSH, [get_modified_interface, req]],
    [TIMEOUT, 3],
    ...
"""

prg2 = """[
    [OPCODE, [arguments, blah]],
    ...
"""

...

prgN = """..."""

for prg in prg1, prg2, ..., prgN:
    try:
        prg = eval(prg)
    except NameError:
        continue
    f(prg)

-- 
Arnaud



More information about the Python-list mailing list