What could be some reasons why a class is not visible unless imported directly from a function?
<p>Example:</p>

<pre><code>import user

class Thing(object):

    def doSomething(self):

        u = user.User(1)
        print u.name

&gt;&gt;  UnboundLocalError: local variable 'user' referenced before assignment
</code></pre>

<p>But this works:</p>

<pre><code>class Thing(object):

    def doSomething(self):

        import user
        u = user.User(1)
        print u.name
</code></pre>

<p>Thanks for your help!</p>

<p>Edit:</p>

<p>But this works:</p>

<pre><code>import user as anothername

class Thing(object):

    def doSomething(self):

        u = anothername.User(1)
        print u.name
</code></pre>
