access surrounding class

Simon simon.12.ghum at spamgourmet.com
Thu Dec 5 16:23:14 EST 2002


Hello,

imagine a construction like this:

class theholy:
    def dosth(self):
        print "a grrrail??"
        self.coconut=1231
        self.rabbit=12
        class snake:
            def donothing(self):
                print "yes, a grrrail"
                # NOW... how can I get the value of coconut?
                # super.self.coconut=1423: ????
                # does not work
        a=snake()
        a.donothing()
a=theholy()
a.dosth()

How can I access coconut or rabbit from within snake??



More information about the Python-list mailing list