Answers for "python get methods and attributes of object"

1

get object attributes python

for att in dir(your_object):
    print (att, getattr(your_object,att))
Posted by: Guest on March-05-2021
0

how to view all attributes and methods of an object python

class Person:
    def __init__(self,name,age):
        self.name = name
        self.age = age
    def printInfo(self):
        print("name: {}, age: {}".format(self.name,self.age))

p1 = Person('Tom',24)
# right below
print(p1.__dict__)
Posted by: Guest on February-10-2021

Code answers related to "python get methods and attributes of object"

Python Answers by Framework

Browse Popular Code Answers by Language