Arg, forgot to post to the mailing list again. -_-<br><div class="gmail_quote"><br>On a smaller issue, don't you need to do:<div class="im"><br><br>class DebugA(BaseA):<br>    def __init__(self):<br></div>        BaseA.__init__(self)<br>
        return<br><br>As in, explicitly call the __init__ function when you initalise DebugA, since DebugA extends BaseA?<br>
<br>I'm just getting this "necessary" step because my books say so. If anyone has a good explanation, please do tell.<br><br>Best regards,<br><br clear="all">Ching-Yun "Xavier" Ho, Technical Artist<br>

<br>Contact Information<br>Mobile: (+61) 04 3335 4748<br>Skype ID: SpaXe85<br>Email: <a href="mailto:contact@xavierho.com" target="_blank">contact@xavierho.com</a><br>Website: <a href="http://xavierho.com/" target="_blank">http://xavierho.com/</a><div>
<div></div><div class="h5"><br>
<br><br><div class="gmail_quote">On Sun, Jun 21, 2009 at 6:26 AM, Lorenzo Di Gregorio <span dir="ltr"><<a href="mailto:lorenzo.digregorio@gmail.com" target="_blank">lorenzo.digregorio@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Jun 20, 8:43 pm, Dave Angel <<a href="mailto:da...@ieee.org" target="_blank">da...@ieee.org</a>> wrote:<br>
<div><div></div><div>> Lorenzo Di Gregorio wrote:<br>
> > Hi,<br>
><br>
> > I'm wondering what would be the preferred way to solve the following<br>
> > forward reference problem:<br>
><br>
> > ---------------------------------------<br>
> > class BaseA(object):<br>
> >     def __init__(self):<br>
> >         return<br>
><br>
> > class DebugA(BaseA):<br>
> >     def __init__(self):<br>
> >         return<br>
><br>
> > # here I would have a prototype of class A which is the same as class<br>
> > BaseA<br>
><br>
> > class B(object):<br>
> >     def __init__(self):<br>
> >         self.obj = A()<br>
> >         return<br>
><br>
> > if __name__ == "__main__":<br>
> > #    class A(BaseA): # Uncomment this for using BaseA objects<br>
> > #       pass<br>
> >     class A(DebugA): # Uncomment this for using DebugA objects<br>
> >         pass<br>
> > ---------------------------------------<br>
><br>
> > I can figure out some ways to fix this but none seems satisfying.<br>
> > Either they are too specific or too cumbersome.<br>
> > A runtime redefinition of class A does not seem to work either.<br>
> > What would be the most "pythonesque" solution other than sorting out<br>
> > the class order?<br>
><br>
> > Best Regards,<br>
> > Lorenzo<br>
><br>
</div></div><div>> You haven't shown us any problem.  class B works fine with a forward<br>
> reference to A.  Now if you were trying to subclass A before defining<br>
> it, that'd be a problem.  Or if you were trying to make an instance of B<br>
> before defining A.<br>
><br>
> Better put some code together with enough meat to actually show a<br>
> symptom.  And tell us what sys.version says.  I'm testing with   2.6.2<br>
> (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)], running<br>
</div>> on Win XP.- Hide quoted text -<br>
><br>
> - Show quoted text -<br>
<br>
Thank you for your help: I'm working on a rather large source, but I<br>
think I have isolated the problem now.<br>
This listing generates an error:<br>
<br>
-----------------------------------------------<br>
<div>class BaseA(object):<br>
    def __init__(self):<br>
        return<br>
<br>
class DebugA(BaseA):<br>
    def __init__(self):<br>
        return<br>
<br>
</div>class B(object):<br>
    def __init__(self,test=A()):<br>
<div>        self.obj = A()<br>
        return<br>
<br>
if __name__ == "__main__":<br>
#    class A(BaseA): # Uncomment this for using BaseA objects<br>
#        pass<br>
     class A(DebugA): # Uncomment this for using DebugA objects<br>
         pass<br>
</div>-----------------------------------------------<br>
<br>
The error happens because Python apparently evaluates the named<br>
arguments before running the script.<br>
I think I have read something about this some (long) time ago but I<br>
can't find it anymore.<br>
<br>
Suggestions?<br>
<br>
BTW, my Python version is 2.6.1 (with latest PyDev).<br>
<br>
Thx!<br>
<div><div></div><div>Lorenzo<br>
--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br>
</div></div></div><br>