By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,715 Members | 758 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,715 IT Pros & Developers. It's quick & easy.

How would i see .pyc files when i execute a python file

P: 2
I wanted to see the python compiled files (.pyc) when i execute python .py files.
help me how would i get .pyc files generated.
Nov 21 '06 #1
Share this Question
Share on Google+
6 Replies


bartonc
Expert 5K+
P: 6,596
I wanted to see the python compiled files (.pyc) when i execute python .py files.
help me how would i get .pyc files generated.
The .pyc file is generated automatically when you execute python a .py file from the command line (python mymodule.py) and it will be in the same directory as the .py file that you executed. IDLE has a curious way of not doing this which I don't understand. Most other IDEs will generate the .pyc files also.
Nov 21 '06 #2

bartonc
Expert 5K+
P: 6,596
I wanted to see the python compiled files (.pyc) when i execute python .py files.
help me how would i get .pyc files generated.
You can force IDLE to generate a .pyc file of "aModule.py" like this:

in "myModule.py" type:
Expand|Select|Wrap|Line Numbers
  1.  
  2. import aModule
  3.  
then, in the menu:
Run-> Run Module
Nov 21 '06 #3

P: 2
Thanks for the reply . I got it
Nov 22 '06 #4

bartonc
Expert 5K+
P: 6,596
Thanks for the reply . I got it
Any time. Keep posting,
Barton
Nov 22 '06 #5

Subsciber123
P: 87
As long as this thread is still open, the easiest way to compile a python file into .pyc is the following:

You have a file, "C:/documents and settings/user/not_compiled.py". You want to compile that file. Create another python file in the same directory. In that file, type "import not_compiled". That will run the program as a module, but it will also compile the program into a .pyc file in the same directory as the original file.
Dec 1 '06 #6

bartonc
Expert 5K+
P: 6,596
As long as this thread is still open, the easiest way to compile a python file into .pyc is the following:

You have a file, "C:/documents and settings/user/not_compiled.py". You want to compile that file. Create another python file in the same directory. In that file, type "import not_compiled". That will run the program as a module, but it will also compile the program into a .pyc file in the same directory as the original file.
Isn't that what I said?
Dec 1 '06 #7

Post your reply

Sign in to post your reply or Sign up for a free account.