module not callable - why not?

Terry Reedy tjreedy at udel.edu
Fri Apr 9 14:10:25 EDT 2004


"Diez B. Roggisch" <deetsNOSPAM at web.de> wrote in message
news:c56jph$rrk$05$1 at news.t-online.com...
> Hi,
>
> I just thought about creating a module for quaternions (as an personal
> exercise, so I'm not after pointers to classlibs here).
>
> Now usually I'd create a file called "quaternion.py", define my
quaternion
> class in there and then import and create an instance like this:
>
> import quaternion
> q = quaternion.quaternion()
>
> Thats a lot to type. doing a

which is why I might add 'as q' to the import

> from quaternion import quaternion
> would solve that - but AFAIK thats considered bad for some reasons.

By who?  and why would you let whoever override your preference ;-)
I have only read suggestions that one be careful with from x import *.

> Now my question is: Is there a way to make a module callable that way?

No.  And I believe Guido has said he doesn't want modules to be classes, or
more classlike.

 >And wouldn't it make sense to allow the implementation
> of a call operator on module level?

To you it seems to ;-)

Terry J. Reedy







More information about the Python-list mailing list