Arg decoding with a template?

Chui Tey teyc at
Fri Aug 3 06:12:59 CEST 2001

How about exploiting the python parser ?

>>> args="arg1, arg2, arg3='world'"
>>> s='def f(%s): pass' % args
>>> exec(s)
>>> dir(f.func_code)
['co_argcount', 'co_code', 'co_consts', 'co_filename', 'co_firstlineno',
gs', 'co_lnotab', 'co_name', 'co_names', 'co_nlocals', 'co_stacksize',
>>> print f.func_code.co_argcount
>>> print f.func_code.co_varnames
('arg1', 'arg2', 'arg3')
>>> print f.func_defaults


Dale Strickland-Clark <dale at> wrote in message
news:ljidmtouqj6som2t9ecagbkj95c53kjaeh at
> Is there a class that simplifies high-level argument decoding under the
control of a template?
> Such a class would take a string as a template and the arg list and return
another list populated
> with keys, values and switches taken from the args.
> I've spent the last hour going through the global module list. If it's
there, its got a daft name!
> --
> Dale Strickland-Clark
> Riverhall Systems Ltd

More information about the Python-list mailing list