Explain This To Me As If I Were a Small Child – Python Interactive Interpreter

I used to work with a guy who would, when trying to understand the mess of a design I just made, ask me to (facetiously), “explain it to me as if I were a small child.” I never liked teach things that way because it always felt insulting to the target audience. However, I sometimes find myself in situations where people I’m teaching say the following:

Him: “Wait, I didn’t know you could do that!”

Me: “Oh, I just thought you knew.”

Now I’m not insulting, I’m a terrible teacher.

So, let’s start from the beginning, as if you were a small child.

Python is an interpreted language. It means that the script that you write isn’t compiled directly into machine code. It get sent into an interpreter that then translates it into machine code on the fly. We’ll come back to this in a second.

What happens when you want to jump in and try a language? Usually, you start with your favorite editor (hopefully not Notepad), write your generic “Hello, World!” program, load that file into the interpreter, and marvel at what your fingertips hath wrought.

Let’s do one better. Let’s launch the Python interactive interpreter.

Woah, what’s this? It’s an interactive Python shell. You can try Python code out live. Go ahead. Try it.

There. Hello, world, without having to touch Notepad. (You should really consider a better text editor).

What’s the point of this? You can, of course, learn about the language and try out new reserved keywords. It’s also good for trying out new libraries, seeing the exact format a function returns.

When you’re working with a new library, it would be nice to know what classes are in a package, or what methods are in a class. Traditionally, you would call dir() to see what is available.

It would be nice if we could get some tab completion in here. Enter ipython. You can get it via apt, yum, or pip.

Tab completion!

Now get out there and start exploring.