Type unification and modules

Guido van Rossum guido at python.org
Sun Sep 9 01:04:29 EDT 2001


Pekka Pessi <Pekka.Pessi at nokia.com> writes:

> 	Now that Python types and classes are being unified, should the
> 	exceptions about modules be removed, too?  I mean things like
> 	__call__, __getattr__, or __setattr__ not working.

I'm not sure what you mean; can you elaborate with an example?  Do you
want to be able to call a module?  Why?

The __getattr__ and __setattr__ methods work on modules, but I'm not
sure if that's what you are thinking about:

    >>> import sys
    >>> sys.__getattr__("path")
    [...something...]
    >>> 

Do you want to be able to override __getattr__ and __setattr__ in
modules?  That has nothing to do with the type/class unification; a
module is still not the same as a class.  But you could write a
subclass of the module type that supported any special method you
like.

--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-list mailing list