[Tutor] Name of a module within itself

alan.gauld@bt.com alan.gauld@bt.com
Sun, 22 Jul 2001 21:09:05 +0100


>  Thanx for replying....although I can't really use it like 
> you said. Let me explain, here's what I'm trying to do:

> class Sub1(Base):
> 	ObjA = 'foo'
> 	....
> class Sub2(Base):
> 	ObjA = 'bar'
> 
> def main():
> 	....
> 	x = funcReturnsSub1orSub2() # x can be either a Sub1 or a Sub2
> 	y = getattr([refer to this module], x).ObjA
      y = x.ObjA

should be exactly the same! You have x as areference to an 
object so just use it, thats what polymorphism is all about!

Alan G