How to use Python well?

Terry Reedy tjreedy at udel.edu
Wed Feb 16 17:33:02 EST 2011


On 2/16/2011 1:35 PM, snorble wrote:
> I use Python a lot, but not well. I usually start by writing a small
> script, no classes or modules. Then I add more content to the loops,
> and repeat. It's a bit of a trial and error learning phase, making
> sure I'm using the third party modules correctly, and so on. I end up
> with a working script, but by the end it looks messy, unorganized, and
> feels hacked together. I feel like in order to reuse it or expand it
> in the future, I need to take what I learned and rewrite it from
> scratch.

Not a completely bad idea, except for the 'from scratch' part. Parts of 
code that work may just need reorganizing.

The most import thing is automated tests. They should grow with the 
code. Tests are like having a safety net.

> If I peeked over a Python expert's shoulder while they developed
> something new, how would their habits differ? Do they start with
> classes from the start?

Depends on whether the particular purpose needs user-defined classes or 
is fine with functions using built-in classes.

-- 
Terry Jan Reedy




More information about the Python-list mailing list