(please help me clarify the title)
This is what I'd like to do:
s = "'arg1', 'arg2', foo='bar', baz='qux'"
def m(*args, **kwargs):
return args, kwargs
args, kwargs = m(magic(s))
# args = ['arg1', 'arg2']
# kwargs = {'foo': 'bar', 'baz'='qux'}
What is the definition of magic()?
Parsing the string myself is a last resort since it's fraught with pitfalls (what if arg1 has a comma in it? what if arg2 has quotes in it? etc).
scomes from the user, any non-horrendously-complicated ways to do this will be full of security risks.scomes from a configuration file. The bulk of the file is not Pythonic at all, but I'm building in some macro-handling that will benefit from this sort of syntax.