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__(sel f,index):
return index
module=Module()
__getitem__=mod ule.__getitem__
---------------------------
file m1.py (main program):
import m2
print m2.__getitem__( 17) # prints 17
print m2[17] # raises error
------------------------------
thanks
Honza Prochazka
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__(sel f,index):
return index
module=Module()
__getitem__=mod ule.__getitem__
---------------------------
file m1.py (main program):
import m2
print m2.__getitem__( 17) # prints 17
print m2[17] # raises error
------------------------------
thanks
Honza Prochazka