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

1 Answer

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


class Test:
    pass


o = Test()
o.language = "Python"
function(o)
 
'''
run:
 
Python
 
'''

 



answered Feb 8, 2018 by avibootz

Related questions

...