A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 5 years ago

How do I create a text file for a program I've written? Where should I put the extension .py ?

  • This Question is Closed
  1. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

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

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.