Sunday, June 6, 2021

Our Engineering Team Used Python's AST to Patch 100,000s of Lines of Code

import ast

# Simple code that sets a variable var to 1 and then prints it.
code = """
var = 1
print(var)
"""

# Converts code to AST. Object 'head' points to the head of the AST.
head = ast.parse(code)

print(head)


from Hacker News https://ift.tt/3vRNw1d

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.