statement level resumable exception
ilejn
ilja.golshtein at gmail.com
Thu Jan 20 15:32:56 EST 2011
Arnaud,
good idea, though I think it is not applicable in my case,
because my arg1 ... argN are "complex multilayer lists".
In reality it is not just
f(arg1),
it is more like
f([[subarg1, 'aa', subarg2], []])
Regarding your remark it is a strange problem ... well, may be it
is ;)
Thanks anyway.
On Jan 20, 10:58 pm, Arnaud Delobelle <arno... at gmail.com> wrote:
> ilejn <ilja.golsht... at gmail.com> writes:
> > Hello!
>
> > I have a sequence of a function calls. Basically it looks like
>
> > f(arg1)
> > f(arg2)
> > ...
> > f(argN)
>
> > though real arguments are complex multilayer lists.
>
> > The problem is some arguments are not known and I get NameError
> > exceptions.
>
> > The solutions I know
> > 1. wrap every f call in try/except block
> > 2. make (currently global) argument attributes of a class and use
> > __getattr__ to convert unknown attributes to something recognizable by
> > f.
>
> for name in 'arg1', 'arg2', ... 'argN':
> try:
> arg = globals()[name]
> except NameError:
> continue
> f(arg)
>
> But this is a strange problem... Sounds like you should do it
> differently.
>
> --
> Arnaud
Best regards,
Ilja Golshtein.
More information about the Python-list
mailing list