It's a big snake, right?
June 20, 2010 8:16 AM   Subscribe

I know next-to-nothing about computers. Or programming. I want to learn Python!

Ok, so I know nothing about the internal logic and bits of computers (most technological AskMes fly right past me) but I have decided I want to learn Python. The internet seems to have lots and lots of resources for this, but I am having trouble distinguishing the signal from the noise on this one. What resources are great for someone who knows nothing about programming and wants to learn Python?

Notes: I have a Mac, I don't know if this matters. If I should be pursuing some other language or method of approaching this, let me know!

I have seen this question and this question but I am more looking for resources/how-tos/ guides/handholding, and not potential finished products. And that second one is from a few years ago, so there may be new material by now, I am assuming.

Also, any tips you yourselves can give me would be appreciated - seriously, GUI? IDLE? Shells? We're talking total novice here, I don't even really know if those terms are on topic!
posted by hepta to Technology (27 answers total) 66 users marked this as a favorite
 
http://www.tutorialspoint.com/python/index.htm

http://www.sthurlow.com/python/

Are two that I found, although I'm not sure of the specifics on getting a working python environment on Mac.

A couple suggestions based on my programming learning experience:

Start small and don't get overwhelmed. Don't worry about the intimading vocabulary like functions/recursion/polymorphism/etc. Just follow and copy code -- physically typing it out by hand and not just copy/paste -- giving yourself the small successes like seeing "Hello World" printed out on the screen.

When I don't understand a concept or a patch of code from a tutorial, I'll write it out, erase it, then write it out again. It helps establish the connection between your active, thinking logic and the internalizing it into your memory.

A great way to learn about anything (programming is perhaps one of the most taught, documented subjects on the net) is to type in a concept or vocab word you come across, and then append "tutorial" to the end of it in a google search.

Youtube is a great place for visual learning and tutorials. Here are a couple links for python for beginners (notice that some of them are multipart tutorials, so keep plodding through them)

http://www.youtube.com/watch?v=29mq1Bn52GY
http://www.youtube.com/watch?v=4Mf0h3HphEA

Don't get discouraged! I tell beginners over and over again who are impressed with some piece of code that Ive written -- it is not as hard as it looks. In fact, once you grasp the basic foundation of programming, it's very easy to learn all the other languages. What the real magic of programming is? Problem-solving -- learning how to see a problem and then work backwards to tell the computer how to solve it.
posted by coldblackice at 8:27 AM on June 20, 2010


*intimidating.... :)
posted by coldblackice at 8:28 AM on June 20, 2010




I won't tell you that Python is a bad choice, because it's a great language for beginners, and there are a ton of resources. I'd argue that Ruby is just as intuitive and easy to learn, though, and likewise has fantastic resources. Most notable are the Pragmatic Programmer's Guide, and the delightfully bizarre Why's Poignant Guide to Ruby. The Ruby on Rails framework also makes it really simple to build web applications, so if you think a project like a simple blog or dynamic website sounds like something you'd like to try, Ruby may be a good choice.

No matter what language you choose, I give this advice to everyone who asks about learning programming. For pete's sake, don't just learn python for the sake of learning to program: wading through a book page by page is dull and pointless. Instead, find an itch and scratch it.

Choose a project - it might be a simple to-do list, or a game that plays blackjack, or a program that crunches some numbers for work. Whatever it is, it'll give you a goal, and you can then learn the bits and pieces that you need to accomplish it. Read the first chapter or two of a book to get up and running, and then just dive in and mess around until you get things working. Don't reduce coding to the same kind of stupid regurgitation you did in high-school math class - you'll miss the essence of programming, which really all about problem-solving, and the sense of accomplishment you get when you bend those bits to your will.
posted by chrisamiller at 8:39 AM on June 20, 2010


While IDEs are incredibly useful later on, I would recommend to start programming with a simple editor. Preferably with syntax highlighting, but not more.
posted by Triton at 8:39 AM on June 20, 2010


ShowMeDo has a collection of videos for the beginning programmer. I wrote this to help people learn about programming. Sadly, I don't have a nicely packaged version for the Mac; you would need to download the .zip files, extract them, and also download wxPython ... but you would then be all set. If you choose to use rur-ple, feel free to email me with any questions you may have.
posted by aroberge at 8:40 AM on June 20, 2010


One question I would have is: why?

Not that it's a bad idea to learn Python (or programming in general), but learning Python is like learning to use a table saw or a router. The ultimate purpose is to make something (a game or a bookcase) and I'd advise that you figure that out first and then start on the language. I'd note that whenever I try to learn a new programming language I always pick some sort of project in that language (for Python it was a graphical front-end to a database to help me keep track of my books and for Java it was a simple game) to provide a goal. You may not be able to come up with a goal immediately, but learning a language without any idea of how you are going to apply it will not, IMHO, be an enjoyable experience.

Others have suggested good resources, but I'll just note that it's named after Monty Python's Flying Circus and not the snake.
posted by It's Never Lurgi at 8:46 AM on June 20, 2010


I should have added ... before downloading rur-ple to try it out, you may want to have a look at this old video and see if this type of approach would appeal to you.
posted by aroberge at 8:47 AM on June 20, 2010


I've heard good things about: How to Think Like a Computer Scientist: Learning with Python. At this point you probably shouldn't worry about using IDLE or any other IDE - a decent text editor with syntax highlighting should be more than enough. I don't use a Mac, but apparently TextWrangler is good.

One of the other great things about Python is the community. Here's a list of mailing lists, newsgroups and forums. In particular you might be interested in the Tutor list. which is a dedicated mailing list for people learning Python.
posted by xchmp at 10:04 AM on June 20, 2010


Best answer: This question could have been written by me! I recently (as in a few days ago) took on learning Python as a summer project. Like you, I am a complete programming newbie, and am not even super great with computers. I have been blazing through Invent with Python and really enjoying it. You can download the book as a PDF for free, which is great. It's geared a little bit towards kids who want to program, but I don't find it overly patronizing, and for me, the slightly playful style works well. There are also some useful tools on the website that go along with the book. Feel free to MeMail with questions!
posted by Polyhymnia at 10:12 AM on June 20, 2010


I have decided I want to learn Python.
Yeah, really, what's the "why", here?

Deciding you want to do this is like deciding you want to learn how to fix Volvo engines. What we need to know is if you have a Volvo, or do you even drive one? Do you have friends with Volvos? Or are you just actually curious about cars and want to know what goes on under the hood?

For instance, if you just want to make your Mac do clever things, you could do worse than starting with AppleScript or Automator. If you want to do things with mathematics, you could look at Mathematica. If you learn with imagery, Processing might be a great place to start.

None of those are like starting with Python or Ruby, or Perl, or even C, but that's because they have different goals in mind. If you want to be a professional programmer, mastering the machine and lord of bits, then you probably want to start with just a text editor and a command line, yes. But if you just want to do cool things, there are better bangs for your buck.
posted by bonaldi at 11:09 AM on June 20, 2010


Nthing Python for all the reasons above, and if you need a 'purpose' to learn it, you could try working through the Python Challenge programming riddles. Frustrating and delightfully tricky.
posted by Xany at 11:31 AM on June 20, 2010 [1 favorite]


Best answer: Not that it's a bad idea to learn Python (or programming in general), but learning Python is like learning to use a table saw or a router.

Yeah, really, what's the "why", here?

If you want to do things with mathematics, you could look at Mathematica. If you learn with imagery, Processing might be a great place to start.

Not to take away from the motivating power of lining up goals, or of a specific project that scratches an itch you've got, but unless the Asker has something rather specialized in mind, this is just overthinking things. Python is a good general purpose language that's viable for most applications. It's a perfectly acceptable tool whether you want to do data visualization or calculate things or automate system administration or write a little game. There are other similarly good languages, but they're probably not appreciably better or worse than Python, which will do fine as an introduction.

Sometimes the goal is just to get an introduction to the territory. In this case, picking *something* and a tutorial and a book and just starting to type the examples and modify them will work out just fine. I started out as a kid who was typing largely useless BASIC programs into TI, Commodore, and Apple computers, straight out of various instruction manuals or magazine code listings. Bumped my shins a lot but had a good time and learned quite a bit... enough to begin recognizing and scratching my own itches, at any rate.
posted by weston at 12:45 PM on June 20, 2010


It's a perfectly acceptable tool whether you want to do data visualization or calculate things or automate system administration or write a little game.
Yes, but using Python means some of those things are much further out of reach for a complete programming novice than they are with languages and environments that are designed for those goals. It takes 20 seconds with Automator to convert an HD h.264 movie file into one designed for iPod, while learning enough Python to do the same will take months.

There's a real hair-shirt attitude to learning "programming" you get from coders sometimes, as if using a terminal and vi are the sole routes to making computers do what you want.

Sometimes the goal is just to get an introduction to the territory
Absolutely. But OP hasn't stated their goal, hence asking for clarification.
posted by bonaldi at 1:20 PM on June 20, 2010


coldblackice: "Start small and don't get overwhelmed. Don't worry about the intimading vocabulary like functions/recursion/polymorphism/etc. Just follow and copy code -- physically typing it out by hand and not just copy/paste -- giving yourself the small successes like seeing "Hello World" printed out on the screen."

The vocabulary may be unimportant per se, but it's hard to learn functions or recursion if you can't talk about them, and you absolutely, absolutely need to understand both.

I would recommend the exact opposite approach: start by using Python as a purely functional language, no assignments or any other side effects. Calculate the Fibonacci or Collatz numbers, or build some recursively-defined data structures like binary trees or disjoint sets. Implement map, fold, reduce, and accumulate, and then use them to flatten some lists. Learn list comprehensions and generators. Look over the itertools and functools modules.

If you're wondering when you'll ever need this again, the answer is you probably won't. But it's a great way to learn recursion and functions, and those you will need every single day. (Also, if you're interested in functional programming you'll find a lot of people on the internet who are really excited about using it all the time. Who knows? Maybe you'll be one of them.)
posted by d. z. wang at 2:03 PM on June 20, 2010


On preview:

b1tr0t: "This is certainly an easier process than on Linux, and probably easier than on Windows. Selecting perl (don't) or Ruby would require exactly as much effort. Ruby and Python are equally good choices. I continue to be amazed that perl does not violate any of the Geneva conventions."

How about we hold off on the holy wars? Perl has its place, as do Python and presumably Ruby too. (I don't know any Ruby, so I can't actually say.) And as a Mac sysadmin who just spent the better part of a day wrestling with an installation that took all of twenty minutes on his Debian dev server, I'll have you know that even Mac has its rough edges. (Oh, so many of them! please don't MeMail me for details.)
posted by d. z. wang at 2:08 PM on June 20, 2010


There's a real hair-shirt attitude to learning "programming" you get from coders sometimes, as if using a terminal and vi are the sole routes to making computers do what you want.

I'm not sure where you're getting this -- not a bit of it is meant behind my comment.

I'm mostly trying to head off anything close to the misconception that if the Asker wishes to learn programming, they have to worry about researching / picking the "right" language for it, or have a project in mind, or even figure out "why" they want to do it.

Those things can be helpful points of focus, but they can also impose cognitive overhead on exploration for exploration's sake. They're not something you *have* to start with. It's totally OK to just sit down, read things, and type and run snippets of code. And which language matters less than time spent doing that.

Of course, if I'm wrong and the Asker really did mean to ask "I want to learn to do video transcoding programmatically" or "I want to chop, press, and smoke Excel spreadsheets," well, the question of the relative accessibility of various libraries and facilities for doing that between various languages is indeed relevant, but at this point, I'm taking the question at face value.

It takes 20 seconds with Automator to convert an HD h.264 movie file into one designed for iPod, while learning enough Python to do the same will take months.

If anyone has either bothered to write a Python-specific video transmogrification library, or a bridge to the Apple libraries Automator uses to do its job, this is incorrect. I don't actually use Python frequently enough to know if either is the case, but it seems likely enough that I suspect this statement is hyperbolic at best.
posted by weston at 2:45 PM on June 20, 2010


I'm mostly trying to head off anything close to the misconception that if the Asker wishes to learn programming, they have to worry about researching / picking the "right" language for it, or have a project in mind, or even figure out "why" they want to do it.

Ha, well I'm trying to head off the misconception that as soon as someone says they want to learn programming the only way forward is to sit down and type some code in and have it evaluated at a command line. I suspect we're not going to agree, here!

it seems likely enough that I suspect this statement is hyperbolic at best.
It's not. To get from start to finish with Automator, including learning the tool, could be done in 10 minutes tops. To get to the point with Python where you can find a possibly-non-existent library or bridge, learn file handling, run your code etc? More than 10 minutes. Much more. (I'm assuming that in both cases you want to understand what's going on, not just c&p from the web)

Hepta definitely has something that piqued her interest in Python. Given that she says she can't understand technical matters, it's not unwarranted to assume what sparked her interest was a more concrete goal than just programming qua programming (particularly since a given language was mentioned). If we know that goal, we can do a lot better than this blundering around in the dark we're doing.

Hepta?
posted by bonaldi at 3:14 PM on June 20, 2010


I'll add Learn Python The Hard Way to Ask MeFi's collection of Python resources.

You're asked to copy code exactly as it is typed, then think about why the script worked the way it did. Great stuff.
posted by achompas at 5:50 PM on June 20, 2010 [1 favorite]


Response by poster: Hello! I did not mean to spark a debate like this, although it is interesting to see.

I want to learn to program as an abstract thought project, basically. It seems interesting, there is plenty of immediate right/wrong feedback, and far outside my normal realm of study/interest. I picked Python because it was recommended to me by a programmer friend, however he didn't fully elaborate on why so it could likely have been personal preference. It stuck with me, though.

I have no real goal in mind, mostly because I don't know enough to know what I would be capable of. This doesn't bother me; I mostly just want to get my feet wet, putter around, keep myself occupied. Weston has it spot-on with "It's totally OK to just sit down, read things, and type and run snippets of code." This is what I want to do!

Thanks, everyone, for the resources.
posted by hepta at 6:47 PM on June 20, 2010


Dive Into Python
posted by kirkaracha at 7:52 PM on June 20, 2010


Sorry, Dive Into Python 3 is more current.
posted by kirkaracha at 7:54 PM on June 20, 2010


b1tr0t: "People new to programming should look to Python, Ruby, Java or another language that more strongly encourages good development habits."

It sounds like OP's already settled on Python, but in case he's still considering other languages: not Java!
posted by d. z. wang at 8:06 PM on June 20, 2010


If you're looking for that itch to scratch, and you're good with math or would like to be, I'd recommend http://projecteuler.net/ , which gives a series of programming problems that generally build upon the problem that came before.
posted by pcowden at 9:09 PM on June 20, 2010


Ha, well I'm trying to head off the misconception that as soon as someone says they want to learn programming the only way forward is to sit down and type some code in and have it evaluated at a command line.

You're completely right that it's not the only way. Having introduced people to Scratch, Excel/VB Macros, and Flash, not to mention my own experiments with MAX, pd, Reaktor, ProGraph, and Novell's Visual AppBuilder, I'm on board with that. These things can be brilliant introductions and broadly serviceable tools, even though they do tend to have certain ceilings text-symbolic tools don't. If hepta had asked about visually-oriented introductions to programming, I'd have leaned that direction and wouldn't have mentioned Python.

But to bring this back to the implied meta-question of "how to learn"... some of my experience teaching people with both visual tools and text-symbolic tools suggests that there's not a ton of difference in what you have to do/learn to use either one effectively. Take HTML, with either a tool like Dreamweaver or a good text editor. It's well understood that if you want to do layout on a web page "by hand", you have to know your various HTML tags and style sheet positioning rules. But the interesting thing is how much of that you still have to know with a visual tool -- you still have some idea in your head of something like a table/grid or of various other positioned containers in your head, along with an idea of how these things behave and what kind of properties/parameters you can give them. The fact that you're invoking menus and dialogs and positioning things with a mouse doesn't change this core of things you really have to understand.

Now, there are some real advantages for visual tools. You don't have to keep a vocabulary in your head, because you can use spatial memory to recall invocation. The environment can nicely organize these things for you and even prompt you (though a number of text-based tools do that these days, too). That not only helps people who either have some recall barriers or don't like looking things up, it can also reduce the fear of arcana that some people experience, which suppresses an important exploratory feeling of play. Seeing those barriers fall instead of keeping those they effect away is worth appreciating.

But it's also worth appreciating the limits of the approach. There's no shortage of people I've watched pick up Dreamweaver (or other tools) and then become disappointed because they thought this was going to be easy and they really weren't determined to do what I think is the most important thing: to have what amounts to a "learning conversation" with the environment they choose to learn and work in. Whether it's by typing in snippets of code to see what happens... or exploring menus, dialog boxes, dragging things hither and yon, and checking the results. It's really largely the same underlying work. You have to sit down, try things out, see what happens, modify things, see what else happens, etc, and this is really what I'm advocating when I'm talking about typing and running snippets of code, not the use of text and a keyboard per se. It just happens that's the way to have that learning conversation with Python.
posted by weston at 12:15 PM on June 21, 2010


Best answer: Hi, me. I was missing me recently, so I asked Professor Hathaway if we could room together.

I digress. My summer project (and will most likely continue through the calendar year and beyond) is to become proficient with Python as well. I started off knowing no programming languages, but I am pretty nerdy, so I can grok the basics of computing and understand more about computers than your typical non-programmer. That said, I'm developing a curriculum as I go, and plan on re-visiting each material after completion to judge its effectiveness. It's going swell so far. Join me.

Text descriptions are taken directly from each respective link's source, so [sic] at your peril. Some of these have been mentioned already but each entry is here for a reason. These all focus on Python 2.x instead of 3.x, which is new(er) and not backwards-compatible. I have heard from multiple sources that new programmers should stick to 2.x until they are comfortable with it before they tackle 3.x.

Goal: Become proficient in Python.

Timeline: Several months.

Plan: Complete each series of materials below in order. Set aside at least an hour each morning uninterrupted to study and follow along said videos and coursework.

Materials:

http://learnpythonthehardway.com/index [web / pdf / html]
This is the site for the book "Learn Python The Hard Way". The book is a very beginner book for people who want to learn to code. If you can already code then the book will probably drive you insane. It's intended for people who have no coding chops to build up their skills before starting a more detailed book.

http://code.google.com/p/crunchy/ [web / interactive]
Crunchy is an application that formats and delivers html-written Python tutorials inside a browser window, adding interactive elements and snazzy navigation.

http://code.google.com/p/rur-ple/ [software]
Learning to program computers should be fun, for adults and children alike. RUR-PLE is an environment designed to help you learn computer programming using the language Python. Within an artificial world in which a robot can be programmed to perform various tasks, you will learn what it means to write a computer program, using Python's syntax. You will also be able to apply your programming skills in a more traditional environment using the built-in interpreter.

http://www.ibiblio.org/swaroopch/byteofpython/read/introduction.html [web / html]
This book will help you to learn the Python programming language, whether you are new to computers or are an experienced programmer.

http://www.greenteapress.com/thinkpython/html/book002.html [web / html]
Python for Software Design is a concise introduction to software design using the Python programming language. Intended for people with no programming experience, this book starts with the most basic concepts and gradually adds new material. Some of the ideas students find most challenging, like recursion and object-oriented programming, are divided into a sequence of smaller steps and introduced over the course of several chapters.

http://www.amazon.com/gp/product/1598631128/ [paperback]
"Python Programming for the Absolute Beginner." As part of the for the absolute beginner series developed by computer science instructors exclusively for Cengage Learning Course Technology PTR, this book will teach you the basics of Python programming through simple game creation. You can then take the skills you learn and use them for more practical Python programming applications and real-world programming scenarios. Better still, by the time you finish this book you will be able to apply the basic principles you've learned to the next programming language you tackle. Create simple, fun games while you learn to program with Python.

http://academicearth.org/courses/introduction-to-computer-science-and-programming [web / video]
This subject is aimed at students with little or no programming experience. It aims to provide students with an understanding of the role computation can play in solving problems. It also aims to help students, regardless of their major, to feel justifiably confident of their ability to write small programs that allow them to accomplish useful goals. The class will use the Pythonâ„¢ programming language.

http://openbookproject.net/thinkCSpy/ [web / html]
How to Think Like a Computer Scientist - Learning with Python 2nd Edition

http://showmedo.com/club/joinus?smdc=socb [web / video]
The ShowMeDo club will allow you access to some special videos we're making to pass on programming skills we consider important to the development and enjoyment of Free Open Source Software (FOSS). The focus at the moment is on developing with the Python programming language, one of the backbones of the FOSS movement with a huge number of included and third-party libraries. [One year's subscription costs $60.]

http://www.mindview.net/Books/TIPython [web / html]
"Thinking in Python." This is not an introductory Python book. This book assumes you've learned the basics of Python elsewhere. I personally like Learning Python by Lutz & Ascher, from O'Reilly. Although it does not cover all the Python 2.0, 2.1 and 2.2 features that I use in this book, most books don't at this point.

http://www.diveintopython.org/ [web / html]
Dive Into Python is a Python book for experienced programmers. You can buy a printed copy, read it online, or download it in a variety of formats. It is also available in multiple languages.

From what I can tell, anyone can learn it as long as you are patient, persistent, and can maintain a genuine interest. Best of luck to you.
posted by ehamiter at 12:19 PM on June 22, 2010 [12 favorites]


So, there's a programmer's question-and-answer site called Stack Overflow. If you're stuck on something, search the site, and if someone hasn't already answered your question, the community there is always glad to answer.

Ask clearly, give examples of where you're stuck, and if your question has no "right" answer, please click the community wiki button. :-)
posted by talldean at 6:38 AM on June 26, 2010


« Older Dogs and public parks   |   Strategy for maximizing tax benefit on new vehicle... Newer »
This thread is closed to new comments.