(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).
With
sandmdefined as you have them: