<br><br><div class="gmail_quote">On Mon, Jan 23, 2012 at 1:44 PM, Jonno <span dir="ltr"><<a href="mailto:jonnojohnson@gmail.com">jonnojohnson@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I have a pretty complicated bit of code that I'm trying to convert to more clean OOP.<div><br></div><div>Without getting too heavy into the details I have an object which I am trying to make available inside another class. The reference to the object is rather long and convoluted but what I find is that within my class definition this works:</div>


<div><br></div><div>class Class1:</div><div>    def __init__(self):</div><div><br></div><div>    def method1(self):</div><div>         foo.bar.object</div><div><br></div><div>But this tells me "global name foo is not defined":</div>

<div><br></div><div>class Class1:</div><div>     def __init__(self):</div><div>           foo.bar.object</div><div><br></div><div>Obviously I want the object to be available throughout the class (I left out the self.object = etc for simplicity).</div>

<div><br></div><div>Any ideas why I can reference foo inside the method but not in __init__?</div>
</blockquote></div><br><div>If it matters, foo is an instance of wx.App and bar is a wx.Frame within the app.</div>