title: NameError : name 's' is not defined
body: <p>I am new to Python. I am trying to create a class which only allows to objects to be created. I am using a private variable instance to keep track of count .
  My Code -</p>
  
  <pre><code>class s:
      __instance=2
  
      if s.__instance&lt;2:
          def __init__(self,x):
              s._instance = x
              s._instance = s._instance+1
              print(s._instance)
  
  a=s(5)
  </code></pre>
  
  <p>When i run the code i got -</p>
  
  <pre><code>"C:\Users\PIYU\AppData\Local\Programs\Python\Python36\python.exe" 
  "C:/Users/PIYU/PycharmProjects/PythonProgram/singleton.py"
    Traceback (most recent call last):
      File "C:/Users/PIYU/PycharmProjects/PythonProgram/singleton.py", line 1, in &lt;module&gt;
      class s:
      File "C:/Users/PIYU/PycharmProjects/PythonProgram/singleton.py", line 4, in s
      if s.__instance&lt;2:
      NameError: name 's' is not defined
  </code></pre>