<div class="gmail_quote">On Tue, Sep 13, 2011 at 5:46 PM, Prasad, Ramit <span dir="ltr"><<a href="mailto:ramit.prasad@jpmorgan.com">ramit.prasad@jpmorgan.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div lang="EN-US" link="blue" vlink="purple"><div><div class="im"><p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas">>You should be passed super the current class you want the super class of, not the type of the super class. So it should be:<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas">>super(<b>B</b>, self).log('system') # Notice that it passed class B<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas"><u></u> <u></u></span></p>

</div><p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas">Ugh, apologies for the poor English; my tea has not kicked in.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas"><u></u> <u></u></span></p>

<p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas">That first line would be more understandable as:  ‘You should pass the current class (B) you want the super class of, not the type of the super class (A) itself. So it should be:’<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:Consolas">To clarify, by passing A to super it retrieves the definition for the base class (object) which does not have the function you are trying to access.</span><span style="font-size:11.0pt;color:#1F497D"><u></u><u></u></span></p>

<div class="im"><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"><u></u> <u></u></span></p><div><p class="MsoNormal"><span style="font-size:10.5pt;font-family:Consolas;color:#1F497D">Ramit</span></p></div>

</div></div></div></blockquote><div><br></div><div>Thanks for helping me clarify on how to use super() in Py2+. That really worked!</div><div><br></div><div><div>>>> class B(A):</div><div>...     def __init__(self, module):</div>

<div>...             self.module = A.log(self, module)</div><div>...             print self.module # printing here is completely unnecessary in a good OOP language</div><div>...</div><div>>>> c = B('system')</div>

<div>logged</div><div>>>> class B(A):</div><div>...     def __init__(self, module):</div><div>...             print super(B, self).log('system') # printing here is completely unnecessary in a good OOP language</div>

<div>...</div><div>>>> c = B('system')</div><div>logged</div><div>>>></div></div><div><br></div><div>When an instance of a class is created, all codes within that instance block should be executed. That's my understanding of OOP.</div>

<div><br></div><div>Thanks everyone!</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div lang="EN-US" link="blue" vlink="purple"><div><div class="im">

<div><p class="MsoNormal"><span style="font-size:10.5pt;font-family:Consolas;color:#1F497D"><u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:10.5pt;font-family:Consolas;color:#1F497D"><u></u> <u></u></span></p>

<p class="MsoNormal"><span style="font-size:10.5pt;font-family:Consolas;color:#1F497D"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:10.5pt;font-family:Consolas;color:#1F497D">Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:10.5pt;font-family:Consolas;color:#1F497D">712 Main Street | Houston, TX 77002<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:10.5pt;font-family:Consolas;color:#1F497D">work phone: <a href="tel:713%20-%20216%20-%205423" value="+17132165423" target="_blank">713 - 216 - 5423</a><u></u><u></u></span></p>

</div><p><span style="color:black;background:white"> </span><u></u><u></u></p></div></div></div><div><div></div><div class="h5">
<p><span style="color:#000000;background-color:#FFFFFF">
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 <a href="http://www.jpmorgan.com/pages/disclosures/email" target="_blank">http://www.jpmorgan.com/pages/disclosures/email</a>.  
</span></p></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Odeyemi 'Kayode O.<br><a href="http://www.sinati.com" target="_blank">http://www.sinati.com</a>. t: @charyorde<br><br>