Talks at PyCon that Teach How to Be Better Programmers

Robert Brewer fumanchu at amor.org
Tue Oct 24 12:26:47 EDT 2006


Jeff Rush wrote:
> ...we need more talks that actually teach you how
> to be better programmers...What the Heck Does
> "Pythonic Programming Style" Mean Anyway?

I'm finishing an outline for a talk which will overlap this one a bit,
but under the topic "What makes a great API?" that will be directed more
at library authors than users:


I. Zero learning required
=========================

"""Civilization advances by extending the number of important operations
which we can perform without thinking about them."""
    -- Alfred North Whitehead, Introduction to Mathematics (1911)
    http://www.quotationspage.com/quote/30283.html

"""To be Pythonic is to avoid surprising experienced Python programmers
with unfamiliar ways to accomplish a task."""
    -- Martijn Faassen
    http://faassen.n--tree.net/blog/view/weblog/2005/08/06/0

1. Use native types, functions and idioms.
    a. Bare functions are better than class collections
    b. getters and setters considered harmful
2. Inventing new types: use Python idioms instead of inventing your own
    a. conform to Python API's
    b. subclass builtins rather than delegating
    c. judicious use of descriptors
3. DSLs suck
4. "Imagine your dream code and figure out how to make it happen"

But when you need to learn/remember something, the API must be...

II. Inspectable
===============

1. If help() is to be helpful, you must reduce [len(dir(obj)) for obj in
all_obj].
2. Dynamic languages naturally more lang-maven oriented?
   See http://osteele.com/archives/2004/11/ides

III. Programmable
=================

1. Config and other "declarative" modes: No "XML sit-ups"

IV. Readable = Simple
=====================

1. Parameterization and customization


Robert Brewer
System Architect
Amor Ministries
fumanchu at amor.org



More information about the Python-list mailing list