title: Why am I getting AttributeError: Object has no attribute?
body: <p>I have a class MyThread. In that, I have a method sample. I am trying to run it from within the same object context. Please have a look at the code:</p>
  <pre><code>class myThread (threading.Thread):
      def __init__(self, threadID, name, counter, redisOpsObj):
          threading.Thread.__init__(self)
          self.threadID = threadID
          self.name = name
          self.counter = counter
          self.redisOpsObj = redisOpsObj
          
      def stop(self):
          self.kill_received = True
              
      def sample(self):
          print &quot;Hello&quot;
                  
      def run(self):
          time.sleep(0.1)
          print &quot;\n Starting &quot; + self.name
          self.sample()
  </code></pre>
  <p>Looks very simple ain't it. But when I run it I get this error</p>
  <p><code>AttributeError: 'myThread' object has no attribute 'sample'</code> Now I have that method, right there. So what's wrong? Please help</p>
  <p>Edit: This is the stack trace</p>
  <pre><code>Starting Thread-0
  
  Starting Thread-1
  Exception in thread Thread-0:
  Traceback (most recent call last):
  File &quot;/usr/lib/python2.6/threading.py&quot;, line 525, in __bootstrap_inner
  self.run()
  File &quot;./redisQueueProcessor.py&quot;, line 51, in run
  self.sample()
  AttributeError: 'myThread' object has no attribute 'sample'
  
  Exception in thread Thread-1:
  Traceback (most recent call last):
  File &quot;/usr/lib/python2.6/threading.py&quot;, line 525, in __bootstrap_inner
  self.run()
  File &quot;./redisQueueProcessor.py&quot;, line 51, in run
  self.sample()
  AttributeError: 'myThread' object has no attribute 'sample'
  </code></pre>
  <p>I am calling it like this</p>
  <pre><code>arThreads = []
  maxThreads = 2;
  
  for i in range( maxThreads ):
      redisOpsObj = redisOps()
      arThreads.append( myThread(i, &quot;Thread-&quot;+str(i), 10, redisOpsObj) )
  </code></pre>
  <p>Sorry, I can't post the redisOps class code. But I can assure you that it works just fine</p>