In the previous fact, we have seen that Python doesn’t have static keyword. All variables that are assigned a value in class declaration are class variables
We should be careful when changing value of class variable. If we try to change class variable using object, a new instance (or non-static) variable for that particular object is created and this variable shadows the class variables. Below is Python program to demonstrate the same.
Initially a.stream = cse b.stream = cse After changing a.stream a.stream = ece b.stream = cse
We should change class variables using class name only.
a.tream = cse Class variable changes to mec Value of variable steam for each object a.stream = mec b.stream = mec
This article is contributed by Nikhil Kumar Singh. If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Object Oriented Programming in Python | Set 1 (Class, Object and Members)
- Overriding Nested Class members in Python
- Text-To-Speech changing voice in Python
- Build an Application for Changing PC's Wallpaper using Python
- PyQt5 - Changing border of Progress Bar
- PyQt5 - Adding/Changing caption of Check Box
- PyQt5 - Changing size of Indicator in Check Box
- PyQt5 - Changing color of pressed Push Button
- PyQt5 - Changing background color of Label when hover
- PyQt5 - Changing background color of Push Button when mouse hover over it
- PyQt5 QSpinBox – Changing value using stepBy method
- PyQt5 QSpinBox - Setting/Changing Geometry
- PyQt5 QCalendarWidget - Changing Cursor Shape
- PyQt5 QCalendarWidget - Changing Geometry
- PyQt5 QColorDialog - Changing Font
- PyQt5 QCommandLinkButton - Changing Icon
- MoviePy – Changing Image and Time at same time of Video Clip
- MoviePy – Changing Display Frame of Video Clip
- MoviePy – Changing Time Line of Video Clip
- PyQt5 QScrollBar – Changing its Orientation