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 195 views
2 answers 238 views
2 answers 201 views
1 answer 186 views
2 answers 166 views
...