Official website for Linux User & Developer

Python development – the golden rules

by Kunal Deo

As part of his Python Development Masterclass, Kunal Deo drew up some golden rules when working with Python. Have you got any Python gems to share?

As part of his massive Python Masterclass article, Kunal Deo drew up some golden rules when working with Python. Click here to jump straight to the article, or add a few of your own golden rules in the comments thread below…

Keep it simple
“Things should be as simple as possible, but no simpler.” (Einstein)

Do one thing well
The UNIX Philosophy certainly applies here.

Don’t fret!
Don’t fret too much about performance – plan to optimise later when needed.

Go with it
Don’t fight the environment and go with the flow.

No-one’s Perfect
Don’t try for perfection because ‘good enough’ is often just that.

Minor shortcut
(Hence) it’s okay to cut corners sometimes, especially if you plan to optimise later.

Learn from the masters
Borrow ideas from elsewhere whenever it makes sense.

Think Cross-platform
The Python implementation should not be tied to a particular platform. It’s okay if some functionality is not always available, but the core should work everywhere.

Stop bugging me (that’s Window’s job)
Don’t bother users with details that the machine can handle.

A large complex system should have multiple levels of extensibility. This maximizes the opportunities for users, sophisticated or not, to help themselves.

Senseless fatalities
Errors should not be fatal. That is, user code should be able to recover from error conditions as long as the virtual machine is still functional. At the same time, errors should not pass silently.

Bug off
A bug in the user’s Python code should not be allowed to lead to undefined behavior of the Python interpreter; a core dump is never the user’s fault.

You can find Linux User & Developer’s Python Development Masterclass here.

twitter follow us
  • Tell a Friend
  • Follow our Twitter to find out about all the latest Linux news, reviews, previews, interviews, features and a whole more.
    • How about test first? Or at least *some* mention of testing in these rules!

    • Russell Barnes

      That’s a platinum rule, not a gold one ;o)

    • Jens

      Yup, it certainly is a good idea to launch an “import this” from time to time to get a perspective again.

    • jackd

      Aren’t these cliched? Trite? Anyone with just a small measure of common sense could have come up with this list.

      e.g., “Borrow ideas from elsewhere whenever it makes sense.” … golly, I never would have thought of *that*.

      I guess this makes me a troll. The actual python tutorial was quite qood, though.