Python: Do not use IDLE

Look — a new Python 3 resource for you.

In the middle of chapter 1 in Automate the Boring Stuff with Python, Sweigart invites you to leave the interactive Python shell (where you have the >>> prompt) and create a little program in a file.

Do not use IDLE. We are never using IDLE.

Instead, you can use Atom, our trusted code editor. Code is code. You can write any code in Atom. Instead of saving the file with a .html or .js extension, we save it with a .py extension when it is a Python file.

Then, how do you run it? Never try to run a file at the >>> prompt. You need to be at the bash prompt ($) in Terminal, or the PowerShell prompt if you’re using Windows.

It’s easiest if you are in the same directory where the .py file was saved. Use your cd command (Command Line Tips) to get there. (I made a folder named automate for my files from the book.)

At the bash prompt, type this (using your actual filename, of course)

python3 myfilename.py

And it runs!

Here’s where that comes in the chapter:

Screen Shot 2018-02-02 at 6.38.49 PM

Here’s what the program looks like in Atom:

Screen Shot 2018-02-02 at 6.26.11 PM

Here’s how I ran it in Terminal:

Screen Shot 2018-02-02 at 6.44.01 PM

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s