class Foo:

    def __init__(self):
        self.x = "x = 1"
        self.y = "y = 2"

    def showx(self):
        print self.x

def showy(self):
    print self.y

if __name__ == '__main__':

    # Attach at runtime
    Foo.showy = showy

    f2 = Foo()
    f2.showx()
    f2.showy()