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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chatpratap
    New Member
    • Nov 2006
    • 2

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

    I wanted to see the python compiled files (.pyc) when i execute python .py files.
    help me how would i get .pyc files generated.
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    Originally posted by chatpratap
    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.

    Comment

    • bartonc
      Recognized Expert Expert
      • Sep 2006
      • 6478

      #3
      Originally posted by chatpratap
      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.p y" type:
      Code:
         
      import aModule
      then, in the menu:
      Run-> Run Module

      Comment

      • chatpratap
        New Member
        • Nov 2006
        • 2

        #4
        Thanks for the reply . I got it

        Comment

        • bartonc
          Recognized Expert Expert
          • Sep 2006
          • 6478

          #5
          Originally posted by chatpratap
          Thanks for the reply . I got it
          Any time. Keep posting,
          Barton

          Comment

          • Subsciber123
            New Member
            • Nov 2006
            • 87

            #6
            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.

            Comment

            • bartonc
              Recognized Expert Expert
              • Sep 2006
              • 6478

              #7
              Originally posted by Subsciber123
              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?

              Comment

              Working...