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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -