• anonymous
How do I create a text file for a program I've written? Where should I put the extension .py ?
MIT 6.00 Intro Computer Science (OCW)
  • Stacey Warren - Expert
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
  • chestercat
I got my questions answered at in under 10 minutes. Go to now for free help!
  • anonymous
If you're using IDLE and you're in the window titled "Python Shell," you need to select "New Window" from the File menu. This will open a window in IDLE's text editor, where you can type your program. When you select Save As, you should MANUALLY add the '.py' extension to the end of the filename. Otherwise IDLE will save the file as .txt. You will still be able to run it normally, but you will lose the benefit of IDLE's color coding, smart indent and call tips features. Any .txt file containing valid code can be used as a module, however it's best to change it to type '.py' to take advantage of IDLE's editing features. If your question is "I just typed a series of statements into the Python Shell window; how can I save the process it just completed as a program?" then as far as I know the only way to do that is to manually copy and paste the commands out of the shell and into a new window--just the commands, not the prompts or any output or error messages. You'll have to be careful to maintain correct indentation and formatting if that's what you're trying to do.

Looking for something else?

Not the answer you are looking for? Search for more explanations.