python 3.x - Instance methods use -


i define class this:

class foo1():     def a():         pass      def b():         pass      def c():         pass 

and create 2 instances of class foo1:

f1 = foo1() f2 = foo1() 

now try print information of methods:

print("f1.a@" , f1.a) print("f1.b@" , f1.b) print("f1.c@" , f1.c)  print('xxxxxxxxxxxxxxxxxxxx')  print("f2.a@" , f2.a) print("f2.b@" , f2.b) print("f2.c@" , f2.c) 

and happen?

f1.a@ <bound method foo1.a of <__main__.foo1 object @ 0x10217d128>> f1.b@ <bound method foo1.b of <__main__.foo1 object @ 0x10217d128>> f1.c@ <bound method foo1.c of <__main__.foo1 object @ 0x10217d128>> xxxxxxxxxxxxxxxxxxxx f2.a@ <bound method foo1.a of <__main__.foo1 object @ 0x10217d160>> f2.b@ <bound method foo1.b of <__main__.foo1 object @ 0x10217d160>> f2.c@ <bound method foo1.c of <__main__.foo1 object @ 0x10217d160>> 

so why instance of class foo1, methods of @ same address?


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 -