virtual inner classes in python?

kasper graversen kbilsted at hotmail.lala.com
Tue Sep 9 18:13:19 EDT 2003


hello there.

I've just started learning python. I see methods are declared virtual by 
default as in Java. Nice. However, the inner class construct seems to be 
even weaker as that of Java. Not nice! :-( Why are inner classes not 
virtual? will they be in a near future? What other language can you 
recomend, if python cannot provide what I need?

My problem is that in the __init__ below, I cannot instantiate "Foo" but 
have to explicate "Test.foo".. secondly, I want to instantiate the "Foo" in 
test2 rather than in tester in the current example..

class Test:
    def __init__(self):
        lala = Test.Foo()
        lala.show()
        class Foo:
        def show(self):
            print "Test.foo.show"


class Test2(Test):
    class Foo:
        def show(self):
            print "Test2.foo.show"


if __name__ == "__main__":
    start = Test2()



hope to hear from you soon ;)

\kasper

-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/




More information about the Python-list mailing list