Accessing parent objects

D'Arcy Cain darcy at VybeNetworks.com
Sat Mar 24 14:14:01 EDT 2018


I'm not even sure how to describe what I am trying to do which perhaps
indicates that what I am trying to do is the wrong solution to my
problem in the first place but let me give it a shot.  Look at the
following code.

class C1(dict):
  class C2(object):
    def f(self):
      return X['field']

O1 = C1()
O1['field'] = 1
O2 = O1.C2()
print(O2.f())

I am trying to figure out what "X" should be.  I know how to access the
parent class but in this case I am trying to access the parent object.
I tried various forms of super() but that didn't seem to work.

-- 
D'Arcy J.M. Cain
Vybe Networks Inc.
http://www.VybeNetworks.com/
IM:darcy at Vex.Net VoIP: sip:darcy at VybeNetworks.com





More information about the Python-list mailing list