Message184842
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:40 | larry | set | recipients:
+ larry, rhettinger, ncoghlan, benjamin.peterson |
2013-03-21 04:45:40 | larry | set | messageid: <1363841140.16.0.06952232126.issue17490@psf.upfronthosting.co.za> |
2013-03-21 04:45:40 | larry | link | issue17490 messages |
2013-03-21 04:45:40 | larry | create | |
|