module not callable - why not?

Heather Coppersmith me at privacy.net
Sun Apr 18 09:08:37 EDT 2004


On 18 Apr 2004 02:28:50 -0700,
Paul Rubin <http://phr.cx@NOSPAM.invalid> wrote:

> Josiah Carlson <jcarlson at uci.edu> writes:

>> I think of modules as a namespace.  Why?  Because that is what
>> they are. They contain a space of names, some of which may be
>> useful to you, otherwise you wouldn't have imported the module.

> Is a class instance not also a namespace?  After all, it
> contains a space of names, some of which you must have wanted or
> else you wouldn't have instantiated it.

> And yet, you can call a class instance if it has a __call__
> operation defined.  I don't see why modules shouldn't be the
> same.

In that light, IMO, __call__ methods are the kluge.  This argument
seems to go back to (1) the old programs vs. data debate, and (2)
the meaning of "functions are first class objects."  Note that
modules are neither functions nor objects.

If I really want to call (the top-level code in) a module, I can
always reload it:

Regards,
Heather

-- 
Heather Coppersmith
That's not right; that's not even wrong. -- Wolfgang Pauli



More information about the Python-list mailing list