Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #12451

RE: Get reference to parent class from subclass?

From "Prasad, Ramit" <ramit.prasad@jpmorgan.com>
Date 2011-08-30 17:26 -0400
Subject RE: Get reference to parent class from subclass?
References <20110828140024.f945cf73052f0c39b0a22a99@johnohagan.com>
Newsgroups comp.lang.python
Message-ID <mailman.583.1314739602.27778.python-list@python.org> (permalink)

Show all headers | View raw


-----Original Message-----
From: python-list-bounces+ramit.prasad=jpmorgan.com@python.org [mailto:python-list-bounces+ramit.prasad=jpmorgan.com@python.org] On Behalf Of John O'Hagan
Sent: Saturday, August 27, 2011 11:00 PM
To: python-list@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.  

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

RE: Get reference to parent class from subclass? "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2011-08-30 17:26 -0400

csiph-web