python - print object name, when object call a function inside the class -
#!/usr/bin/env python class aa(object): def __init__(self): pass def y(self): pass x=aa() x.y()
when execute x.y(), want print "this 'x' call me", how should ?
i hope solve issue
#!/usr/bin/env python class aa(object): def __init__(self): pass def y(self, name): self.name = name print("this %s call me" % name) x = aa() x.y("tarzan")
Comments
Post a Comment