Built In Class Attributes
Every Python class automatically comes with a set of built-in attributes that provide useful information about the class itself, without you needing to define them manually.
Common Built-In Class Attributes
__dict__- a dictionary containing the class's namespace, including its attributes and methods__doc__- the class's docstring, if one has been written__name__- the name of the class as a string__module__- the name of the module in which the class was defined__bases__- a tuple containing the class's parent (base) classes
class Student:
"""Represents a student enrolled in a course."""
def __init__(self, name):
self.name = name
print(Student.__name__) # Student
print(Student.__doc__) # Represents a student enrolled in a course.
print(Student.__module__) # __main__
Coming Up Next
Next, you'll learn how Python controls access to class attributes and methods through public, protected, and private conventions.