Monolith149 Daily

Another place to see what KG is doing...

Learning Python

Day 15

What’s the best way to learn the Python programming language? I think the on-line tutorial at python.org is the fastest but it works best if Python isn’t your first language.

Backing Up

I think Python is nearly the perfect language. Okay, it’s not really perfect, but it’s as close as any I can think of. There are other languages that might be better for some extreme, specialized cases (which will not seem extreme or specialized to anyone who works on them every day) such as very low-level system programming, programs where performance is critical, maybe very large corporate software systems (though I’d claim Python still holds it’s own here), as just a few examples.

However, even in those instances, Python does okay.

There are languages for other ways of thinking about programming like the functional languages Haskell, LISP, etc.

What’s great about Python is that it’s short, clear, easy to write once you get the hang of it, very easy to read, and it can handle programs that range from short little scripts to very large, complex systems.

If You’ve Programmed Before

If you’ve written programs before, in any programming language, then you’ll probably be fine using the on-line tutorial for Python. It’s free and on-line at Python’s own website, https://docs.python.org/2/tutorial/.

Start with chapter 1, then do 2-4. Then skip to chapter 7 with more input/output. After than follow up with 5. You can add the additional chapters later, as you either need to or are interested.

If You’re a Beginner

I can’t say I’ve found any beginning books that I’ve looked at and thought, “Yes! That’s the ideal Python book for a beginning programmer.” I am completely convinced that Python is the best language for learning to program since Pascal.

The book Learn Python the Hard Way Third Edition by Zed A. Shaw, Addison-Wesley Professional, 2013, seems pretty good and complete, but it seems slow and plodding to me. That approach may be perfect for you. Pace is always relative. The book is free on-line, available as a PDF you can download, or you can buy the on-line version and get the accompanying videos or buy the regular book.

There seem to be thousands of vidoes teaching you Python on Youtube. As far as I’ve looked, I’ve not found one that I like. There are many that are okay, but none that I’ve bothered to write the URL down for.

The book Learning Python Fifth Edition by Mark Lutz, O’Reilly Media, 2013 is 1600 pages! It’s hard for me to understand how you could make a book on Python that long and I have looked it over. I’m not saying it’s not a good book, it’s apparently complete and I believe it includes exercises and the new Python 3 version. Still, wow!

If you’re a beginner, I think I’d still say take a look at Python’s on-line tutorial and see if it works for you. Try all of the examples. If you run into any trouble, go to one of these other books for that part or look for some videos on Youtube on the specific topic. Then go back and carry on with the tutorial.

What About Java?

And what about Java as a first language? Well, here’s the traditional first program that prints out “Hello, World!” in Java:

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

Compare the same program in Python.

print "Hello, World!"

Now, I understand why the Java program looks they way it does and there are valid reasons for it’s verbosity and what’s going on there. However, I’ve used Python in many large programs and haven’t missed the features of Java even once (knock on wood). I will admit, though, that I’m strangely drawn to Java. I remember when it first came on the scene. I don’t dislike it. I’ve just never found a use for it other than interacting with systems or services that only support Java.

References

The Python Tutorial
Learn Python The Hard Way