This content originally appeared on CodeSource.io and was authored by Ariessa Norramli
In this article, you will learn how to get the content of an object 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.
The post How to Get Content Of A Class in Python appeared first on CodeSource.io.
This content originally appeared on CodeSource.io and was authored by Ariessa Norramli
Ariessa Norramli | Sciencx (2021-02-24T10:30:55+00:00) How to Get Content Of A Class in Python. Retrieved from https://www.scien.cx/2021/02/24/how-to-get-content-of-a-class-in-python/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.