# An empty class class EmptyClass: pass # A global function def fun(self,*arg): print(*arg) print(self) # create an instance before poking old_instance = EmptyClass() # poke fun to EmptyClass EmptyClass.fun = fun # create an instance after poking new_instance = EmptyClass() # the new_instance has method fun: new_instance.fun('calling new_instance.fun') # also the old_instance has method fun: old_instance.fun('calling old_instance.fun') """ calling new_instance.fun <__main__.EmptyClass object at 0x145b021f3be0> calling old_instance.fun <__main__.EmptyClass object at 0x145b021f3c40> """