4 ms·
How to become a proficient Python programmer
- andrewcooke 15y agodespite mentioning algorithms (once), the links in that section are related to language-specific tweaks. so the article seems to assume that the reader is already a competent programmer (or, worse, doesn't understand that language-specific tweaks are much less important than basics). for example, about 6 months ago i rewrote someone's C code into python. this was numerical code for processing astronomy observations and comparing them with numerical models. i reduced the running time from about 24 hours to 15 minutes. that wasn't because python is faster than C (it's not), or because i used python specific idioms (i did, but they made no real difference). it's because i replaced O(n^2) algorithms with linear ones. the lesson being: language is not important.
- super_mario 15y agoNow if you re-write the C code to use O(n) instead of O(n^2) algorithms, you will reduce the runtime even further as compared to the Python runtime. Of course the time cost savings may not be as important or dramatic any more, since the Python version sounds good enough (at least for the data set in question). Runtimes of languages still matter. Same algorithm implementation may run significantly slower in some languages than others (and this is not necessarily the language issue but interpreter/compiler issue).
- jonathansizz 15y agoIt's just a question of planning ahead: for instance I find the best way to code in Python is to lay out all the whitespace first, then add the text in at the end.
- mattgreenrocks 15y agoPlease save your clever one-liners for Reddit.
- kylemaxwell 15y agoThe links include a pretty good explanation of functional programming. When somebody describes something as "the opposite of object-oriented", my ears perk up. I've done procedural programming since the early 80s and never quite got comfortable with OOP in any form. But I like this concept of functions taking only inputs, producing only outputs, and minimizing (or eliminating) any other side effects.
- hercynium 15y agoYet another garbage article on "how to become good at X". Idioms are indeed important, but TDD won't improve your proficiency (except in that you'll learn a testing framework and be writing more code). Neither will attempting to adhere to a "Functional" style when you've not already learned the important lessons of FP from an actually FP-oriented language. Coding guidelines? Be consistent. Discover the guidelines of the code you're working on and use that. That has nothing to do with python or proficiency. Performance is probably the last part of proficiency that one has to learn, and arguably the most difficult. A lot of other skills have to come together before one can count "performance" as a point of their proficiency in a language, and most of those skills are really quite language-agnostic. Oh, and if you're focusing on performance but you don't yet know how to properly profile and benchmark, you're not proficient. If you really want to become a proficient Python programmer (or any other language) try this: 1. Find the documentation 2. Learn how to navigate, search, and read the documentation 3. Find a skilled mentor or some community resource (IRC, mailing-list, website forums, etc) 4. Ask what is considered good code. Read it. Study it. 5. Create a project - little ones, like sorting your MP3 collection or mining your email for statistics. 6. Try to use the lessons learned in the code you've studied when writing your project. 7. lather, rinse, repeat. Chances are, you're not proficient until you're doing it for several hours every day - and even then, you're probably not really "proficient"... yet. /rant off
- bgray 15y ago> 4. Ask what is considered good code. Read it. Study it. Any suggestions?
- Luyt 15y agoSee http://news.ycombinator.com/item?id=327710 http://news.ycombinator.com/item?id=327710
- neutralist 15y agoI'm currently reading Facebook's Tornado web server. They have some demo apps included too. https://github.com/facebook/tornado https://github.com/facebook/tornado
- gaius 15y agoThe article on TDD: it is about giving you a tool to deeply understand your own problem domain However that's not what TDD actually does: http://devgrind.com/2007/04/25/how-to-not-solve-a-sudoku/ http://devgrind.com/2007/04/25/how-to-not-solve-a-sudoku/
- preek 15y agoThe linked author claims that TDD is not a good approach to develop algorithms by linking to an article by Peter Norvig in which he writes tests to develop and further prove correctness of his algorithm. Maybe he didn't write the tests first, but none the less it proves the upmost importance of tests. Btw, Peter Norvig himself has good things to say on TDD[1]. So using him in an argument against TDD whilst he's using tests is kinda self defeating. 1. http://gigamonkeys.wordpress.com/2009/10/05/coders-unit-testing/ http://gigamonkeys.wordpress.com/2009/10/05/coders-unit-test...
- plinkplonk 15y ago"Maybe he didn't write the tests first" Then he isn't doing TDD at all is he? "Test-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle: first the developer writes a failing automated test case that defines a desired improvement or new function, then produces code to pass that test ..." [Wikipedia] Using tests after you write your code, to test functionalty how it needs to be improved has been a common practice from the earliest days of sw dev. In other words, "the importance of tests" has never been in dispute. TDD is not so universally accepted. Testing is beneficial, sure. But the claim that TDD ,sometimes evangelized as "not a testing method, it is a design method" (roll eyes), actually helps in "deeply understanding your problem domain" needs more validation. Due Disclosure: I wrote the original blog post(EDIT: the blog post comparing the two Sudoku attempts not the OP for this HN discussion) . I personally think TDD is overhyped consultantware snake oil, but that is just my personal opinion. If it works for you, more power to you.
- preek 15y agoPlenty validation can be found in whole communities - anything concerning Ruby for example lives and breathes test or behavior driven development. Btw, Peter Norvig himself has good things to say on TDD[1]. So using him in an argument against TDD whilst he's using tests is kinda self defeating. 1. http://gigamonkeys.wordpress.com/2009/10/05/coders-unit-testing/ http://gigamonkeys.wordpress.com/2009/10/05/coders-unit-test...
- limist 15y agoIf the general topic of boosting your Python-fu interests you, be sure to check out this StackOverflow page: http://stackoverflow.com/questions/2573135/python-progression-path-from-apprentice-to-guru http://stackoverflow.com/questions/2573135/python-progressio... And its HN discussion: http://news.ycombinator.com/item?id=1890494 http://news.ycombinator.com/item?id=1890494
- sayemm 15y agoGreat tips, I learned Python a while ago and have been focused on Ruby recently. I wonder what the equivalent of this post would be for becoming a proficient Ruby programmer... any advice, guys? Here are two good Stack Overflow threads: http://stackoverflow.com/questions/1092675/what-ruby-knowledge-should-i-have http://stackoverflow.com/questions/1092675/what-ruby-knowled... http://stackoverflow.com/questions/2569501/what-ruby-and-rails-developers-ought-to-know/2569865#2569865 http://stackoverflow.com/questions/2569501/what-ruby-and-rai...
- preek 15y agoHey sayemm, I'm the author of the article, so thanks a bunch for the praise! I have switched to being a professional Rails programmer four months ago and left the last 2.5 years of daily Python programming behind me. This post is more a by-product of a mail that I answered. Maybe I'll sometimes get around and write a pendant for Ruby. To get you started - for my new job I had to read these seven books: * Agile Web development by Sam Ruby * CSS, the definitve guide * Head first software development * jQuery in Action * pragmatic git * The Rails Way by Obie Fernandez * The Rspec Book Granted, this is less Ruby then Rails specific. Best to you on your path, Alain
- sayemm 15y agoNice, I've got all of those except for the CSS, Head First, and Rspec book... so I'm glad I've been headed in the right direction. Will look into those other books, I hear the RSpec book is real handy. Thanks you so much for the tips and the list. This is why I love Hacker News.