title: How to check if an object has been initialized in python?
body: <p>How to check if an object has been initialized in python?I have <code>my_tac = tac(EDL_port)</code> at multiple places ,in cases where it is already initialized it throws an error shown below..I want to add a check if my_tac is initiliazed or not,how to do that?
  CODE:-</p>
  
  <pre><code>#From another file
  my_tac = tac(EDL_port)
  
  #alpha.py
  class tac:
     ## tac class constructor.
     #
     #  @param self
     #  @param timeout
     #  @param baud_rate
     def __init__(self, port=None, timeout=0.3, baud_rate=115200):
        if port is not None:
           self.port = port
           self.ser = serial.Serial(self.port, baud_rate, timeout=timeout)
           return
        else:
           (tac_ports,spider_ports) = tac_probe_for_devices()
           print "TAC ports..."
     ...................... 
  </code></pre>
  
  <p>ERROR:-</p>
  
  <pre><code>11/5/2016 8:54:05 PM: my_tac = tac(EDL_port)
  11/5/2016 8:54:05 PM: File "C:\CST_QSPR\third_party_bin\BuildLoaderScripts\Android\android_dl\alpaca.py", line 90, in __init__
  11/5/2016 8:54:05 PM: self.ser = serial.Serial(self.port, baud_rate, timeout=timeout)
  11/5/2016 8:54:05 PM: File "C:\Python27\lib\site-packages\serial\serialwin32.py", line 31, in __init__
  11/5/2016 8:54:05 PM: ERROR:adb -s C2687475 remount failed
  11/5/2016 8:54:05 PM: super(Serial, self).__init__(*args, **kwargs)
  11/5/2016 8:54:05 PM: File "C:\Python27\lib\site-packages\serial\serialutil.py", line 236, in __init__
  11/5/2016 8:54:05 PM: self.open()
  11/5/2016 8:54:05 PM: File "C:\Python27\lib\site-packages\serial\serialwin32.py", line 62, in open
  11/5/2016 8:54:05 PM: raise SerialException("could not open port {!r}: {!r}".format(self.portstr, ctypes.WinError()))
  11/5/2016 8:54:05 PM: serial.serialutil.SerialException: could not open port 'COM8': WindowsError(5, 'Access is denied.')
  </code></pre>