[issue17490] Use converter functions to implement ast.literal_eval

2013-03-20 Thread Larry Hastings
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

[issue17490] Use converter functions to implement ast.literal_eval

2013-03-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: FWIW, I like the current version of the code and find it easily to understand what it does and how it does it. The new code is longer and full of indirections. I question whether it is a real improvement. -- nosy: +rhettinger __

[issue17490] Use converter functions to implement ast.literal_eval

2013-03-20 Thread Nick Coghlan
Nick Coghlan added the comment: Now that I've actually implemented it, I'm fairly sure it's not a good idea. It might be better if we remove the recursive behaviour. As it is, Larry's fairly happy with what he is already doing (calling ast.parse and walking the tree) and I think that's actuall

[issue17490] Use converter functions to implement ast.literal_eval

2013-03-20 Thread Nick Coghlan
Changes by Nick Coghlan : Removed file: http://bugs.python.org/file29496/ast_literal_eval_converter_functions.diff ___ Python tracker ___ ___

[issue17490] Use converter functions to implement ast.literal_eval

2013-03-20 Thread Nick Coghlan
Nick Coghlan added the comment: Updated patch attached. The complexity grew a bit, as it turned out to be useful for the converter functions to be able to tell the difference between top level conversions and recursive invocations. I also realised that: - the complex number conversion currentl

[issue17490] Use converter functions to implement ast.literal_eval

2013-03-19 Thread Nick Coghlan
Nick Coghlan added the comment: Heh, that's what I get for wanting to go get dinner. I'll regenerate it in the morning. -- ___ Python tracker ___

[issue17490] Use converter functions to implement ast.literal_eval

2013-03-19 Thread Benjamin Peterson
Benjamin Peterson added the comment: Interesting patch. :) -- nosy: +benjamin.peterson ___ Python tracker ___ ___ Python-bugs-list mai

[issue17490] Use converter functions to implement ast.literal_eval

2013-03-19 Thread Nick Coghlan
Changes by Nick Coghlan : -- nosy: +larry ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.or

[issue17490] Use converter functions to implement ast.literal_eval

2013-03-19 Thread Nick Coghlan
New submission from Nick Coghlan: Currently, ast.literal_eval uses a long if/elif chain to implement the limited parsing of the AST. This issue proposes changing the implementation to make it easy to extend to cover some of the implementation details of PEP 436 (Argument Clinic). -- f