How to Get Content Of A Class in Python
Posted on: February 24, 2021 by Ariessa Norramli
In this article, you will learn how to get the content of a class in Python.
Let’s say you have a class named Dog with attributes breed and origin.
class Dog:
breed = "Siberian Husky"
origin = "Siberia"
In order to the content of a class, you can use the dir()
method.
class Dog:
breed = "Siberian Husky"
origin = "Siberia"
print(dir(Dog))
Note: The dir()
method functions by returning all properties, methods, and built-in properties of an object by default.
Share on social media
//