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 192 views
2 answers 235 views
2 answers 198 views
1 answer 179 views
2 answers 158 views
...