Generate python code as a result of executing Python code

Asked 2 years ago, Updated 2 years ago, 13 views

; It's weird to write a question I'm still a beginner at Python, so I don't think I can express my intention exactly.

;;

I want to make a program that calls Excel and uses the value of a specific cell to make it into Python code. Of course, I want to make this program Python.

input : Excel

Program: Python

output : Python source file

I'm not sure how to create a Python code as a result of Python execution and make it into a file. Ask for examples or advice that might be a hint. Thank you in advance (__)

python

2022-09-22 11:43

1 Answers

It is difficult to generate Python code as a result of execution.

You can perform Python code generated by exec functions, etc., but generating a string according to Python grammar with Excel input values (of course, it can be easy if it is simple).) is formidable.

In other words, it is difficult to make a parser, but it is very convenient to use a parser generator such as antlr.

It would be very helpful if you had a compiler class or made an automata.


2022-09-22 11:43

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.