Beginning with Python, II

Turns out I was correct in my previous post on starting python – Macs come with Python 2 installed, but Windows does not.

But for the life of me, since installing Python 2 on my laptop, I could not get it to run in PowerShell (and here I’ll add that my understanding of command line is as basic as it can be, mainly culled from Zed A. Shaw’s command line crash course).

In case of not having a clear understanding of what happened, but just trusting what I was told to do, I entered

[Environment]::SetEnvironmentVariable(“Path”, “$env:Path;C:/Python27”, “User”)

into PowerShell. This, as far as I understand, configures the path correctly after installing Python. Don’t ask me to explain that, since the previous sentence is literally the full extent of what I understand of what the above did.

And so, using the one command I know in Python, I used Notepad ++  to write the following, uh, program (I titled it – it made sense at the time.) In my previous post I used the IDE PyCharm instead of Notepad ++. I’m using the latter in this post as I wanted to make sure I could run Python in Powershell, which is Microsoft’s command line interface.

Python Exercise 1

And then, in PowerShell, with an easy python, success was had (large arrows added for convenience)

Python Exercise 2

Things happened that I wanted to happen! Today Woodsworth, tomorrow significant contributions to the field!


Beginning with Python

Whoah, hey, so I’ve begun to learn the language Python. I’m really going into this blind, stumbling about and hoping to muddle my way through. So, of course, I’m going to publicly share the process.

1. What is Python & why are you learning it?

I don’t know, everyone else seemed to be doing it. I mean, it seems to be the basis of Programming Historian, and a lot of digital librarians talk about it. A lot. And if I’ve learned one thing in the digital humanities universe, it’s to always listen to librarians.

My older brother is a programmer, on the other hand, and he doesn’t know Python. He told me to learn Java instead. He then told me to learn both at the same time.

So there you go, mixed reviews. Ultimately, I went with Python and not Java because I have a friend in the econ PhD program at my uni, and apparently they all use Python, so we’re learning it together. So, uh, my reasons are peer pressure and a desire to fit in with librarians and economists.

Anyway, Python is a open-source programming language that is widely used, that is considered high-level (meaning, it seems, that a little does a lot), and that can be used to do many different things. To be honest, I can’t tell you more than that. There is more, but it’s beyond me at the moment. (And this all came, by the way, from the Wikipedia entry for Python).

2. Install, etc.

This is where I kinda muddled through. My brother recommended I use the PyCharm IDE (IDE is an integrated development environment, and it’s basically software that makes programming easier than it would be otherwise by providing editing, debugging, and other things I don’t fully understand at the moment.)

My book, however, recommended getting Notepad++.

Programming Historian recommends Komodo Edit.

What follows, including the screenshots, are of PyCharm.

Also, my econ friend uses a Mac and I use a PC, so I think our experiences diverged as this point. Mainly, his PyCharm seemed to come with Python loaded, whereas I had to download it. But I’m not sure, and it’s always possible he was lying to me. (Is “loaded” the correct term in this context? I’m not sure about that, either. So many questions, so few answers!)

Anyway, having downloaded both PyCharm and Python from their respective websites, I was then able to use Python in Pycharm.

3. Do something

Ok, so I opened PyCharm, started a new project (which I called test1) and chose Python as the interpreter.

I then started a new file under test1, chose Python again, named the file ‘helloworld’, and voila


At this point, I just followed the instructions on the first lesson on setting up an IDE for Python (for Windows) from Programming Historian. Basically a print instruction, so that when you run the program, it prints whatever you tell it to. Like “hello world.”


So I ran the program and

pycharm 3

Hello World! It might not be a lot, but it’s a start.

4. Resources

First off, Python has a beginner’s guide that helped me figure out what I was doing (here). And then they have a beginner’s guide for beginners (read: non-programmers), which is what we want.

Second, Programming Historian. So hard.

I’m also using the book Learn Python the Hard Way, 3rd ed., by Zed A. Shaw. If you follow the link, you’ll see that there is a free online edition of the book. If you like that sort of thing.