What are modules really for?
skip at pobox.com
skip at pobox.com
Tue Aug 9 11:45:48 EDT 2005
Nick> One thing I find weird about python is the idea of a module. Why
Nick> is this needed when there are already the ideas of class, file,
Nick> and package?
A module is a namespace object that maps one-to-one to a file (ignoring the
new module's features). A file by itself is just a collection of bytes and
has no features to interpret the structure of its contents as a namespace.
Nick> Python seems to let you group classes together in one file and
Nick> call it a module, but what for?
You can define many other types of objects in modules besides classes.
Nick> With Python an inherited method could be in one of many base
Nick> classes and/or mixins and there seems no particular logic as to
Nick> what the filename would be.
I agree mixins can be troublesome. That's a problem peculiar to multiple
inheritance, not strictly to Python. I'm sure you can create file/class
relationships in Java or C++ that make it challenging to find the definition
of a mixin. I don't view multiple inheritance as a gotta-have feature of
OOP and avoid it when I can. Smalltalk has lived happily without multiple
inheritance for a few decades now.
Skip
More information about the Python-list
mailing list