Get reference to parent class from subclass?

Prasad, Ramit ramit.prasad at jpmorgan.com
Tue Aug 30 23:26:24 CEST 2011


-----Original Message-----
From: python-list-bounces+ramit.prasad=jpmorgan.com at python.org [mailto:python-list-bounces+ramit.prasad=jpmorgan.com at python.org] On Behalf Of John O'Hagan
Sent: Saturday, August 27, 2011 11:00 PM
To: python-list at python.org
Subject: Get reference to parent class from subclass?

class P():
    pass

class C(P):
    pass

Can I get P from C? 

IOW, can I get a reference to the object P from the object C? This should be obvious one way or the other, but I haven't been able to find the answer.

Regards,

John
-- 


You should be able to access what you need via the super() built-in. I am not entirely sure what you are trying to do...but I think usage of super is probably better than trying to access the base classes manually.

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423



This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  



More information about the Python-list mailing list