Larry Hastings added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17490>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to