how to become a really good Python programmer?

Roy Smith roy at panix.com
Wed Jun 16 09:01:52 EDT 2004


Randall Smith <randall at tnr.cc> wrote:
> I've been programming in Python for about 2 years.  I think it offers 
> the best combination of simplicity and power of any language I have 
> explored.  As I write more and larger and complex programs, I need to 
> code better.  By better I mean clearer, cleaner, more efficient and 
> maintainable.  As the subject states, I want to become a really good 
> Python programmer.

What you really want to do is become a really good programmer, who 
happens to write programs in Python.

The virtues you mention; clarity, efficiency, and maintainability, are 
pretty much universal, regardless of what language you write in, 
although I'm not sure I would put them in that order.  For the vast 
majority of code that you'll write, efficiency should not be that high 
on the list.

First off, you want your programs to be correct.  The first step in 
correctness is understanding what they are supposed to do.  If you don't 
know what it's supposed to do, how do you know if it's doing it or not?  
Whether you use some kind of formal specification process, or something 
more dynamic such as the XP folks espouse, don't start writing code 
until you know what you're trying to do.

The second step in making sure your programs are correct is testing.  
You can spend a lifetime learning (and arguing) about the best way to 
test, but any testing is better than none.  Once you start making 
testing an essential part of your process, you'll start to discover that 
some programs are easier to test than others.  Strive to make what you 
write easy to test.

Clarity comes from breaking your program up into logical units 
(functions, classes, modules, etc) which can be understood by 
themselves.  Huge monolithic programs with complex interactions and 
global data are hard to understand.  Good choice of variable and 
function names helps too, as does good use of comments (although, 
exactly what constitutes good use of comments is another whole topic of 
debate).

None of the above is Python specific.



More information about the Python-list mailing list