D
Diez B. Roggisch
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
from quaternion import quaternion
would solve that - but AFAIK thats considered bad for some reasons.
Now I thought about defining a __call__ operator at module level to allow
this:
import quaternion
q = quaternion()
where the call looks like this:
def __call__(*a, *kw):
return quaternion()
But that doesn't work.
Now my question is: Is there a way to make a module callable that way? And
wouldn't it make sense to allow the implementation of a call operator on
module level?
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
from quaternion import quaternion
would solve that - but AFAIK thats considered bad for some reasons.
Now I thought about defining a __call__ operator at module level to allow
this:
import quaternion
q = quaternion()
where the call looks like this:
def __call__(*a, *kw):
return quaternion()
But that doesn't work.
Now my question is: Is there a way to make a module callable that way? And
wouldn't it make sense to allow the implementation of a call operator on
module level?