Is it possible to change an instance's method implementation without changing all other instances of the same class?
<p>I do not know python very much (never used it before :D), but I can't seem to find anything online. Maybe I just didn't google the right question, but here I go:</p>

<p>I want to change an instance's implementation of a specific method. When I googled for it, I found you could do it, but it changes the implementation for all other instances of the same class, for example:</p>

<pre><code>def showyImp(self):
    print self.y

class Foo:
    def __init__(self):
        self.x = "x = 25"
        self.y = "y = 4"

    def showx(self):
        print self.x

    def showy(self):
         print "y = woohoo"

class Bar:
    def __init__(self):
        Foo.showy = showyImp
        self.foo = Foo()

    def show(self):
        self.foo.showx()
        self.foo.showy()

if __name__ == '__main__':
    b = Bar()
    b.show()
    f = Foo()
    f.showx()
    f.showy()
</code></pre>

<p>This does not work as expected, because the output is the following:</p>

<blockquote>
  <p>x = 25</p>
  
  <p>y = 4</p>
  
  <p>x = 25</p>
  
  <p>y = 4</p>
</blockquote>

<p>And I want it to be:</p>

<blockquote>
  <p>x = 25</p>
  
  <p>y = 4</p>
  
  <p>x = 25</p>
  
  <p>y = woohoo</p>
</blockquote>

<p>I tried to change Bar's init method with this:</p>

<pre><code>def __init__(self):
    self.foo = Foo()
    self.foo.showy = showyImp
</code></pre>

<p>But I get the following error message:</p>

<blockquote>
  <p>showyImp() takes exactly 1 argument (0 given)</p>
</blockquote>

<p>So yeah... I tried using <code>setattr()</code>, but seems like it's the same as <code>self.foo.showy = showyImp</code>.</p>

<p>Any clue? :)</p>
