Does Python really follow its philosophy of "Readability counts"?

Mark Wooding mdw at distorted.org.uk
Mon Jan 12 00:53:04 CET 2009


Carl Banks <pavlovevidence at gmail.com> wrote:

[Dynamically adding and removing instance attributes...]

> Here's a couple examples of where it's useful:
> 
> 1. Sometimes classes are initialized without calling __init__, [...]
> 2. Some classes have factory classmethods [...]
> 3. Some objects, such as proxies, have uncertain sets of attributes. [...]
> 4. It allows a simplification of the object system.  [...]

All good points.  I'd like to add a fifth: it can provide a handy hook
for one module to hang data off of another module's objects.  This sort
of thing isn't very nice, but it's sometimes the best way.

(Other approaches include using wrappers, which might be very invasive
if opaque, or don't actually solve the name-collision problem if
transparent; or maintaining a dictionary, which involves messing about
with weak pointers if you want to keep it from filling with cruft.)

> In the end, the answer to you question is simply, "Readibilty counts,
> but other stuff matters too."

Amen.

-- [mdw]



More information about the Python-list mailing list