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 287 views
2 answers 360 views
2 answers 322 views
1 answer 273 views
2 answers 303 views
...