Re: Arg decoding with a template?
by Chui Tey other posts by this author
Aug 3 2001 4:12AM messages near this date
Re: Arg decoding with a template?
|
Re: Arg decoding with a template?
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',
'co_fla
gs', 'co_lnotab', 'co_name', 'co_names', 'co_nlocals', 'co_stacksize',
'co_varna
mes']
> >> print f.func_code.co_argcount
3
> >> print f.func_code.co_varnames
('arg1', 'arg2', 'arg3')
> >> print f.func_defaults
('world',)
Chui
Dale Strickland-Clark <dale@[...].uk> wrote in message
news:ljidmtouqj6som2t9ecagbkj95c53kjaeh@[...]..
> 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
--
http://mail.python.org/mailman/listinfo/python-list
Thread:
Dale Strickland-Clark
David Bolen
Jim Dennis
Marcin 'Qrczak' Kowalczyk
Chui Tey
David Bolen
Hans-Joachim Widmaier
Hans-Joachim Widmaier
Skip Montanaro
Quinn Dunkan
Dale Strickland-Clark
David Bolen
Steve Holden
David Bolen
Alex Martelli
Dale Strickland-Clark
Dale Strickland-Clark
Skip Montanaro
David Bolen
Peter Wang
Steve Holden
David Bolen
Steve Holden
Skip Montanaro
|