[RELAY][RFC] Modify repr to return a valid Python AST
See original GitHub issueI think we should update repr
and by extension the debug printing methods defined in C++ to update a valid Python AST. This would make it possible for us to extract the debug representation when printing it and paste it into a Python file to edit and modify.
I think this will be very useful for experimenting and debugging.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
ast — Abstract Syntax Trees — Python 3.11.1 documentation
The ast module helps Python applications to process trees of the Python abstract syntax grammar. The abstract syntax itself might change with each...
Read more >python - Parse a .py file, read the AST, modify it, then write ...
You can parse the python code (represented in string) by simply calling the API ast.parse() . This returns the handle to Abstract Syntax...
Read more >Python repr() Method (With Examples) - TutorialsTeacher
The repr() function returns the string representation of the value passed to eval function by default. For the custom class object, it returns...
Read more >Python __str__() and __repr__() functions | DigitalOcean
This method is called when repr() function is invoked on the object. If possible, the string returned should be a valid Python expression ......
Read more >RFC 5321: Simple Mail Transfer Protocol
When addresses, rather than free-form debugging information, are returned, EXPN and VRFY MUST return only valid domain addresses that are usable in SMTP ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
My goal is to obtain a program fragment like:
Instead of:
Upon further reflection we could just do this in Python, though there are some challenges due to our name representation.
My main goal is that we could obtain textual representation of the program which can be copy-and pasted back into the interpreter along the idea presented by the
pprint
module (https://docs.python.org/3.7/library/pprint.html).My inspiration is that I was writing tests and debugging some transformations and it would be nice to be able to easily manually edit the AST to observe changes instead of having to write a Relay program to do so.
close due to inactive status