title: Python AttributeError: class has no attribute
body: <p>I have this code with a class queue which consist of <code>simpy</code> <code>Resource</code> and <code>Container</code> (<code>buffer</code>):</p>
  
  <pre><code>class queue:
      def __init__(self, env):
          self.port = simpy.Resource(env, capacity=1)
          self.buffer = simpy.Container(env, init = 0, capacity=1250000000)
          self.mon_proc = env.process(self.monitor_tank(env))
  </code></pre>
  
  <p>But when I want to use the class and it's attribute buffer using</p>
  
  <pre><code>def Packet(env, id, size, port, time_in_port):
  
      arrive = env.now
      yield queue.buffer.put(size)
      print('packet%s %s arriving at %lf' % (id, size, arrive))
  
      with port.request() as req:
          yield req
  
          tip = random.expovariate(1/time_in_port)
          yield env.timeout(tip)
          amount = size
          yield queue.buffer.get(amount)
          print('packet%s %s depart at %lf' % (id, size, env.now))
  </code></pre>
  
  <p>I'm getting the following error when calling queue.buffer</p>
  
  <pre><code>AttributeError: class queue has no attribute 'buffer'
  </code></pre>
  
  <p>Mind to explain why I can't use the attribute from the class?
  Thanks.</p>