Ask HN: What is your best way to learn Python programming language?

18 points by franca ↗ HN
I have no CS background. I want to learn Python as my first programming language.

So what's the best way to learn it and maybe the fastest?

14 comments

[ 2.8 ms ] story [ 41.3 ms ] thread
Why Python? I'm not arguing with you because it's a good first language, but what do you want to accomplish? What do you want to do with Python??
I want to build web apps, do data analysis and publish on Internet, and most importantly it is most recommended language for beginners with lots of resources available online. Do you recommend any other language to start with? I am just curious to know how you learn the language, what you use books, videos, project, or blog post? How you take notes (my hand starts paining after sometime)? What is your framework of learning?
maybe consider trying a static language?
What static language would you recommend? I figure the choices are basically Java or C#. Of the two, I'd likely suggest that Java will be easier only because I think beginners might find .Net a little large to dive into. But I wouldn't call Java a particular compact language that would be good for teaching someone to think like a programmer. What do you think?
The worst language to teach someone as a first language has to be Java. It also might be the worst language to teach someone as a second language.
Java gives me a rash, so writing that last comment took every last bit of restraint I had.

But, I still can't come up with a static language that I'd want to teach someone as a first language. C# would be a good choice, but I don't know how much success a beginner would have with .Net. Typescript is hard to debug unless you know Javascript. I wouldn't wish C++ as a first languge upon anyone. Haskell seems like it would be very frustrating for a beginner. Swift might be okay if they really badly wanted to go mobile, but that's not the case here. Rust is the best I can come up with, though it seems like a tough first language.

Do you have any ideas? I see the value of learning static first, but can't come up with a good language!

Well, I guess if your goal was to learn a statically typed programming language Java or C# would be fine. So I don't disagree with you.

Personally, I have been in the role of teaching people programming, and I have seen what Java does to them. And I remember what it was like when I first encountered it.

So, I don't have a better suggestion if that is the goal. But if the goal is to learn programming, I have plenty to say on that. I worked as a TA for 3 years and from my rather biased experience, I would highly recommend HtDP and Racket.

Chances are that my framework of learning is going to be different than yours. I find that most materials distract me from my real task - getting efficient and productive with a new tool.

I like to learn by doing projects. I'll usually pick three projects that I find somewhat interesting and figure out how to finish them with the new tool. I usually progress like this:

1.) Build the first project. 2.) Build the second project. 3.) Go back, read the first project and refactor it using what I've learned. 4.) Build the third project. 5.) Add a new feature to the first project. 6.) Refactor the second project. 7.) Add a new feature to the third project.

By the time I've made it through those steps, I'm fairly confident with my skills. I likely don't have full mastery of the language and it's ecosystem, but I have found good resources, learned where to ask for help, and learned enough of the ecosystem's language to be able to ask for more detailed help.

I also try to confine my learning to one subject. For example, you mention that you'd like to start doing some data analysis. If you have advanced knowledge in math/stats, that might be a great way to learn. But, if you don't, you'll have to learn the underlying science while you're learning to use the tool. With the way I learn, that is setting me up for failure.

Here is the thing though. My method works for me and I'm using it now to learn a new tool. But, I'm a sample of one.

A fellow named Zed Shaw has written a set of guides to learning new languages. His Learn Python the Hard Way is quite well regarded. Learning a language like that doesn't work as well for me, but that might be the exact way that you learn. To learn more, check out https://learnpythonthehardway.org . If you like taking notes, this might be a good option for you. Only, you might find that your muscle memory improves faster if you type the notes into a computer!

Alternately, there are some great classes that you can take online. MIT offers Introduction to Computer Science and Programming in Python through MITOpenCourseware and ItunesU. I already knew Python when I listened to that series, but I learned one hell of a lot through the lectures.

You'll still have to practice and write lots of code, but hopefully one of those resources helps you progress to the point that you feel your practice is beneficial. The key is to find a style that works for you and keep at it.

Programming is hard, so keeping at it is the most important part. It doesn't much matter how you learn as long as you don't quit. You'll learn the most when you're most frustrated, so take frustration as a sign that you're getting better. Depending on how you motivate yourself, you might want to keep a learning journal so that when you feel dumb you can flip back and realize that you were significantly dumber a month ago. :)

Good luck! And don't be afraid to ask for help. We have all been beginners and most really good developers are all beginners in something. Have fun and kick ass!

Python is a great first language for the use cases you mentioned! We have great popular frameworks for web apps such as Django and Flask; and data analysis tools and frameworks like Pandas, NumPy, and Airflow, amongst many others.
Python is an excellent first language to learn. Many universities around the world now use it as the language by which to introducing programming both for CS and non-CS students.

Depending on how you learn best, the following are 3 effective ways to learn:

From a book - one of the best books is Learning Python (http://shop.oreilly.com/product/0636920028154.do)

From videos - you could search YouTube for a trainer who communicates in a way that resonates for you.

By playing (and writing) games - PyGame is an excellent resource (https://www.pygame.org/docs/tut/PygameIntro.html)

Well written Python programs are like structured English, so they are not that hard to read. Personally I would suggest PyGame as the most effectively way to learn, but it really is a personal taste and preferences thing.

The book I would propose for newbies is "How to think like a computer scientist" by Jeffrey Elkner, Peter Wentworth, Allen B. Downey and Chris Meyers.

Last release is from 2012 and uses Python 3 and it is freely available under GNU Free Documentation License.

Link: http://howtothink.readthedocs.io/en/latest/