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

Mark Wooding mdw at distorted.org.uk
Wed Jan 21 13:45:58 CET 2009


"Russ P." <Russ.Paielli at gmail.com> writes:

> I'm not sure what you mean by "conflating module and class systems."
> Are you referring to the fact that Java requires each class to be in
> its own file of the same name (I don't use Java, but that's what I've
> heard)? If so, I agree that is a bad idea.

No.  I mean that using classes as a unit of access control is wrong.  A
class is a unit of behaviour, but that behaviour can (and often should)
come from a number of places.

Common Lisp gets this right.  Classes define slots for their instances;
slots are named by symbols.  If you can write the symbol, you can access
the slot.  But symbols are managed by packages: packages can export some
symbols and keep others internal; and they can import symbols from other
packages.  The same mechanism works for functions, variables, classes,
types, macros, and all the other random namespaces that Lisp (like most
languages) has.

Python keeps access control separate from classes.  And I think I'd like
it to stay that way.

(Lisp's package system also solves the problem that a class's -- and its
superclasses' -- attributes and methods form a namespace which isn't
well-managed in many languages.  Since CL uses symbols for these, and
symbols belong to packages, MDW::MUMBLE isn't the same symbol as
RUSS-P::MUMBLE and so they name different slots.)

-- [mdw]



More information about the Python-list mailing list