#24 - (OOP) Class Variables in Python

Publié le: 23 mars 2021
sur la chaîne: Tech Vitals
473
15

Learn the difference between a class variable and instance variable. The values of instance variables can be unique or different for each instance or each class object. However, the values of class variables will be same for each class object. Class variables are shared by all instances of a class. Class variables are always defined outside of the class's methods. We can also provide a different value of class variable for specific class object. In such case, only that specific class object will have a distinct value for that class variable, while all the remaining class objects will have the same value for the class variable.
We can access the class variables using the class name as well as object name, but it is preferred to use object name so that we can get correct values even if some class objects have different values for class variables.

Facebook:   / techvitals  


Sur cette page du site, vous pouvez voir la vidéo en ligne #24 - (OOP) Class Variables in Python durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Tech Vitals 23 mars 2021, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 473 fois et il a aimé 15 téléspectateurs. Bon visionnage!