Re: special method in module

2005-11-16 Thread Jan Procházka
Thanks, probably you are right, hacking python in my situation is not neccessary... >Jan Procházka wrote: > > > >>can have modules special methods? >> >> > >no, but you can replace the module object with something that can have >special methods: > >$ more module.py >import sys > >class Modu

Re: special method in module

2005-11-16 Thread Fredrik Lundh
Jan Procházka wrote: > can have modules special methods? no, but you can replace the module object with something that can have special methods: $ more module.py import sys class Module: def __getitem__(self, value): return value sys.modules[__name__] = Module() $ python >>> impor

special method in module

2005-11-16 Thread Jan Procházka
Hello, can have modules special methods? althouht i think that no, i tried following example and i don't, why it don't works: file m2.py (imported module) class Module: def __getitem__(self,index): return index module=Module() __getitem__=module.__getitem