Using Class Variables for Shared Data in Python


Define variables at the class level for values shared across all instances.

Source Code

class Dog:
    species = "Canis familiaris"
    def __init__(self, name, breed):
        self.name = name
        self.breed = breed
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments