Answers for "print all the methods and variables of a class in pythn"

0

python print class variables

# to print out the variable names
print(vars(YourClass))

# to print out names and values
for var in vars(YourClass):
    print(getattr(YourClass, var))
Posted by: Guest on March-06-2020
0

how to get all values from class in python

>>> an = Animal()
>>> attrs = vars(an)
#{'kids': 0, 'name': 'Dog', 'color': 'Spotted', 'age': 10, 'legs': 2, 'smell': 'Alot'}
Posted by: Guest on November-27-2020

Code answers related to "print all the methods and variables of a class in pythn"

Python Answers by Framework

Browse Popular Code Answers by Language