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?
- Please have a look at this SO Answer for the QuestionRohit Vipin Mathews– Rohit Vipin Mathews2015-06-16 11:17:16 +00:00Commented 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.codingsplash– codingsplash2015-06-16 11:18:54 +00:00Commented Jun 16, 2015 at 11:18
Add a comment |
1 Answer
Take a look at the py_compile.compile and its source code to see how it is done.
4 Comments
codingsplash
I get an ImportError at "from py_compile import wrlong"
Vincent
It is
wr_long, I made a typo.codingsplash
It does not recognise wr_long as well. Am I going wrong somewhere?
Vincent
My bad, I didn't notice you're using python 3. I edited the link to the sources.