On 19.03.13 06:45, Larry Hastings wrote:
4. Store a string that looks like the Python declaration of the
signature, and parse it (Nick's suggestion).  For foo above, this would
be "(arg,b=3,*,kwonly='a')".  Length: 23 bytes.

Strip parenthesis and it will be only 21 bytes long.

We'd want one more mild hack: the DSL will support positional
parameters, and inspect.Signature supports positional parameters, so
it'd be nice to render that information.  But we can't represent that in
Python syntax (or at least not yet!), so we can't let ast.parse see it.
My suggestion: run it through ast.parse, and if it throws a SyntaxError
see if the problem was a slash.  If it was, remove the slash, reprocess
through ast.parse, and remember that all parameters are positional-only
(and barf if there are kwonly, args, or kwargs).

It will be simpler to use some one-character separator which shouldn't be used unquoted in the signature. I.e. LF.

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to