2

I have a string print("hello"). I want to directly store this as a .pyc file and execute it later. How can I do this?

2
  • Please have a look at this SO Answer for the Question Commented Jun 16, 2015 at 11:17
  • I am already aware of py_compile, which necessiates a .py file. I want to do the same without a .py file getting created. Commented Jun 16, 2015 at 11:18

1 Answer 1

0

Take a look at the py_compile.compile and its source code to see how it is done.

Sign up to request clarification or add additional context in comments.

4 Comments

I get an ImportError at "from py_compile import wrlong"
It is wr_long, I made a typo.
It does not recognise wr_long as well. Am I going wrong somewhere?
My bad, I didn't notice you're using python 3. I edited the link to the sources.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.