O'Reilly logo

XML Processing with Python by Sean McGrath

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

5.7. Design Principles

There is an old saying in computing that I heartily agree with: “If you have a lot of special cases, the design is wrong.”

Apply this maxim to Python and the inescapable conclusion is that the design is pretty much right! Python has very few special cases, very few “gotchas,” very few “deadly sins” to watch out for. A big part of Python's clean design is that a number of key ideas are applied everywhere. Among these principles are the following:

  • Use lists as a general-purpose data structure.

  • If you need to look something up, use a dictionary.

  • Program the interface, not the implementation.

In the sections that follow, we look at each of these ideas in turn.

5.7.1. Key Idea: Use Lists as a General-Purpose Data Structure

As ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required