Python and new instance
<p>Although i'm familiar with other programming languages, I'm struggling to understand my code in python and why my class properties aren't reset when i reassign the class... eg. I have a method in a notify class</p>

<pre><code>def send(self):
    for service in self.hosts:
      # func = getattr(self, service)
      for host in self.hosts[service]:
        try:
          if service == 'xbmc':
            self.xbmc(host)
          elif service == 'growl':
            self.growl(host)
          elif service == 'prowl':
            self.prowl(host)
        except:
          print "Cound't connect " + host.find('ip').text + " For " + service
</code></pre>

<p>As you can see, this will iterate through each service (so keep in mind I have 3 xbmc's)</p>

<p>so take xbmc for an example, the method is</p>

<pre><code>def xbmc(self, host):
  x = Xbmc(host)
  x.notify(self.title, self.message)
</code></pre>

<p>under other languages, if i would assign x again, it would be a completely new fresh object, but this doesnt seem to be the case with python...</p>

<p>I will place snippets off my xbmc class to explain the issue.</p>

<pre><code>class Xbmc:
  hosts = []
  def __init__(self, host = None):
    self.setHosts(host)
    self.server = Hosts().getHostsByService('xbmcserver')

  def setHosts(self, host = None):
     ...alot of elif...
     elif type(host).__name__ == 'Element': # this code is the one that is in effect from my notify class
       self.hosts.append(host)
     ...more elif...
     print self.hosts # for debugging
</code></pre>

<p>now that the code is there, when i initiate my notify to send. the output shows:</p>

<pre><code>[&lt;Element 'host' at 0x7fdda19d0d10&gt;]
XBMC 192.168.1.10 Failed To Connect
[&lt;Element 'host' at 0x7fdda19d0d10&gt;, &lt;Element 'host' at 0x7fdda1955090&gt;]
XBMC 192.168.1.10 Failed To Connect
XBMC 192.168.1.20 Failed To Connect
[&lt;Element 'host' at 0x7fdda19d0d10&gt;, &lt;Element 'host' at 0x7fdda1955090&gt;, &lt;Element 'host' at 0x7fdda19553d0&gt;]
XBMC 192.168.1.10 Failed To Connect
XBMC 192.168.1.20 Failed To Connect
XBMC 192.168.1.21 Failed To Connect
</code></pre>

<p>its clear that when i append the host, that its never actually a new instance but always appends to what was already there... I assumed x = Class() would initiate a New Instance? if i do</p>

<pre><code>self.hosts = [host]
</code></pre>

<p>then obviously i dont get the undesired effect, but it would be good too know why my initial approch doesnt work or how to overcome it. Do we need a reset method? or is there actually a way to create a new instance off a class? or is there something wrong with my code? thanks....</p>
