views:

135

answers:

1

I'm curious of what other people consider good, Pythonic code.

What I mean by Pythonic are libraries that show off good and idiomatic Python code. Adhering to the guidelines of Python. I.e good naming, correct use of modules and generally following best practices and so on.

What's your favorite idiomatic Python library? Please provide justification for your answer.

+3  A: 

Have you taken a look at the Python standard library source code? It can give you an idea of the different idiosyncrasies for proper Python style. Not all of them follow PEP 8, but you can learn a lot just by looking. I recommend you look at modules contained in a single file, so that you get the full picture. Specific examples within the source include:

  1. CSV
  2. ConfigParser

Keep in mind that this does not mean that these modules should be taken as "exemplary Python code" but the point remains: they are good enough as for them to be included in the standard Python distribution.

For more complex modules, take a look at the standard Email package, or the Django source code. Again, not necessarily following PEP 8, but used by thousands (and loved by many).

It's fair to say that there is a balance between amazing Python code tomorrow versus decent working code today.

Cheers,

Juan

Arrieta