Answers for "python how to access class variable"

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
1

how to access variables from a class in python

class Example(object):
    itsProblem = "problem"


theExample = Example()
print(theExample.itsProblem)
print (Example.itsProblem)
Posted by: Guest on June-03-2020

Code answers related to "python how to access class variable"

Python Answers by Framework

Browse Popular Code Answers by Language