Method override class python

class type ():
DEF original function (Self):
Print ( 'I am the original function!')

def new function (Self):
Print ( 'I am the new function of rewrite!')

a = class () # instantiate
a. the original function ()

# Instead of the original function with a new function, i.e. [Method] override category
class. Primitives = new function

# Original functions have now been replaced by
a. The original function ()

Guess you like

Origin www.cnblogs.com/ldsice/p/11106442.html