Author larry
Recipients benjamin.peterson, larry, ncoghlan, rhettinger
Date 2013-03-21.04:45:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
For what it's worth, here's what we're doing.  The new Argument Clinic "parameter" line looks a great deal like the middle bit of a Python function declaration.  So much so that we can do this:

    ast_string = "def x({}): pass".format(parameter_line)
    root = ast.parse(ast_string)

We then walk the node tree and pull out what we need.  We do a similar trick to parse the return converter, which comes from another line.  ("def x() {}: pass")

The "converter function" can look like a literal string, an id, or a function call.  When we see the function call form, we pull out each keyword and its value, then pass the value node to ast.literal_eval().  Easy peasy and Bob's your uncle.
Date User Action Args
2013-03-21 04:45:40larrysetrecipients: + larry, rhettinger, ncoghlan, benjamin.peterson
2013-03-21 04:45:40larrysetmessageid: <>
2013-03-21 04:45:40larrylinkissue17490 messages
2013-03-21 04:45:40larrycreate