Arnaud, it looks like a solution. Perhaps it is better than plain try/accept and than proxy class with __getattr__. It is not for free, e.g. because syntax check such as parentheses matching is lazy too, though looks very interesting.
Thanks a lot! On Jan 21, 10:41 am, Arnaud Delobelle <arno...@gmail.com> wrote: > ilejn <ilja.golsht...@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 Best regards, Ilja Golshtein -- http://mail.python.org/mailman/listinfo/python-list