Is it possible to dump an arbitrary LibCST node into Python code? My use case is that I want to extract the code for functions that match a specific naming scheme. I can extract the FunctionDef
nodes that I need, but I don't seem to find a way to convert them to code.
LibCST: Converting arbitrary nodes to code
692 views Asked by Georgios Gousios At
1
It is possible using the method
code_for_node
from theModule
class.You use it as follow:
and that would generate the output: