Python 3 Primer: Starting in IDLE

The following post is part of a series. Although written in an idiosyncratic manner mostly for my own edification and amusement, collectively they amount to a kind of quick and quirky basic primer on Python 3. It’s geared toward true coding beginners (of which I remain one) who want a short tutorial before delving into the more complex worlds of online interactive platforms, 800-page books, Ivy League MOOCs, and the plethora of other learning resources both on and off the Web. I hope a few others may find the posts useful or, at least, moderately amusing. 

Basking in Basics: First Steps (How to download Python and IDLE to get started)

Basic One: Where Do You Get Your Python?

Some version of Python might already be on your computer. Have a look. If it’s not there and you’re using Windows, use your Web browser to go to https://www.python.org/downloads/ in order to download Python. If you don’t have Windows, there are links there to versions for other operating systems. It should be fairly easy to download from one of these pages.

Once it’s downloaded, install it, of course.

By the way, you can get “documentation” — aka, stuff you sometimes need to know about Python —  at http://www.python.org/doc/. I have found that some of the explanations of how Python 3 works are comprehensible but some read like the glossolalia to me. Luckily, there are other places to look for help if you’re having issues. I covered some of them in my previous post on Python.

Basic Two: Why Should You Get IDLE?

I think the easiest way to get started with Python coding is by launching “IDLE”.  Once you’ve downloaded Python, look around for the IDLE file. On my computer, it’s in the following subdirectory:

                                                Python310>Lib>idlelib>idle

But the first time I downloaded Python, I found it just by searching for “idle” using Windows Explorer.

IDLE stands for the Python “Integrated DeveLopment Environment” and also is a reference to Eric Idle, one of the founding members of the Monty Python comedy group (Python is name for them). When you first click on the IDLE file, it’ll launch the Python Shell. Here’s what it will look like if you maximize it.

IDLE is just one of many possible integrated development environments (IDEs) you can use, but I found it to be a good place to start. As you work with various Python tutorials, their authors may point you in the direction of other IDEs that have different (and often more sophisticated) features. For a list of some other IDEs, have a look at the Python wiki. Another source on IDEs can be found here.

You can type your first commands directly into the this Shell if you want. Write the following in IDLE and then hit return. (Just remember that the >>> symbols are not something you need to type. They are already in IDLE.)

>>>print (‘Hello, world!’)

You should now see ‘Hello, world!’ pop up. (It’s tradition to use that phrase when starting a new language, so now you’re part of the grandish tradition.)

Anyway, that’s coding, sort of, so now you can say you’ve done it. But, obviously, that’s like saying that you know how to speak Spanish if you’ve only mastered “Hola.” Over time, you’ll pick up the language, but you’ve got to get in there and start plugging away, not caring if the locals are snickering at your weird syntax and lousy grammar at first.

(Don’t worry. At least at first the “locals” are just the programming language and IDLE itself, so there won’t be any actual human scorn involved. Feel free to make as many mistakes as you like. If you have patience and a sense of humor about yourself and Python, it can be a lot of fun).

How Do You Get Out of Your Shell?

From the Python Shell, you can go to the pulldown menu “File” and click on “New File”. It should open up a window that looks like this if you maximize it:

That’s your Text Editor. You should save this window as a file, calling it whatever you want and storing wherever you won’t lose it. Then type in the following once again:

                                                print ('Hello, world!')

Then go to the “Run” drop-down menu, and choose “Run Module.” With any luck, you’ll then see Hello, world printed in the Shell. It’ll go something like this:

First, you’ll type in your code:

print ('Hello, world!')

Then you’ll run the module:

And then the words will be printed in your Python Shell:

In case this wasn’t clear, keep in mind that the Text Editor and the Shell are two different things. You can put commands into your Shell but mostly you’ll be coding in your Text Editor and then running the code. The outcome of that code will show up in the Shell.

I’m hoping that’ll work for you. If not, keep playing around with it, and find other sources of information. Persistence counts in this biz.

PS – If you need it, another step-by-step can be found at RealPython.

Featured image: Group shot of the Monty Python crew in 1969, Back row: Graham Chapman, Eric Idle, Terry Gilliam; Front row: Terry Jones, John Cleese, Michael Palin https://en.wikipedia.org/wiki/Eric_Idle#/media/File:Flyingcircus_2.jpg