Class attributes | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Class attributes

How to get access to all attributes of a class ? for example print all of attributes

25th Feb 2022, 4:33 PM
shokin touch
5 Answers
+ 5
if we wanted to get and print the attributes and values of the object / instance and not of the class as in the sample that Slick provided, we can use: ... print(a.__dict__) put this line outside the class.
25th Feb 2022, 7:11 PM
Lothar
Lothar - avatar
+ 4
A class is a user-defined blueprint or prototype from which objects are created. class Service(object): data = [] def __init__(self, other_data): self.other_data = other_data ...
26th Feb 2022, 2:26 PM
Vaibhav
Vaibhav - avatar
0
@Slick what about the situation we want to print them with their values?
25th Feb 2022, 6:17 PM
shokin touch
0
@vaibhav singh I can't understand yout answer?
28th Feb 2022, 3:11 PM
shokin touch