Name error in Python in 'self' definition
<p>Getting <code>Name Error:</code> in python code as shared below. I am a beginner in Python.</p>

<pre><code>from PyQt4 import QtGui, QtCore
import sys
import I2CGenericFrame
import os

class I2CApp(QtGui.QMainWindow, I2CGenericFrame.Ui_winI2CMain):
    def __init__(self):
        super(self.__class__, self).__init__()
        self.setupUi(self)


    self.cmbBusListBox.addItem("Slect ..")
</code></pre>

<p>It is giving following error.</p>

<pre><code>Traceback (most recent call last):
  File "I2cMain.py", line 6, in &lt;module&gt;
    class I2CApp(QtGui.QMainWindow, I2CGenericFrame.Ui_winI2CMain):
  File "I2cMain.py", line 12, in I2CApp
    self.cmbBusListBox.addItem("Slect ..")
NameError: name 'self' is not defined
</code></pre>

<p>Guide me, Thanks in advance.</p>

<p>the variable <code>self</code> is passed to methods automatically when you call them from an object.  Your line of code <code>self.cmbBusListBox.addItem("Slect ..")</code> is not contained within a method of the Class and therefore it does not know what <code>self</code> is.  This is probably an indentation error.  Did you intend for it to be under <code>__init__</code>?</p>

python linux