How to pass an object to function as an argument to print object method in Python

1 Answer

0 votes
def function(obj):
    print(obj.m)


class Test:
    m = "class test"


o = Test()
function(o)
 
'''
run:
 
class test
 
'''

 



answered Feb 8, 2018 by avibootz

Related questions

1 answer 193 views
2 answers 236 views
2 answers 199 views
1 answer 179 views
2 answers 159 views
...