Thursday, February 28, 2019

Class Attribute vs. Instance Attribute In Python: What You Might Have Missed

As an object-oriented language, Python provides two scopes for attributes: class attributes and instance attributes.

While the instance attribute in Python has exactly the same characteristics and definition as the other object-oriented languages, the class attribute is always mistakingly considered to be the exact equivalent of the static attribute in Java or C++. To be accurate, class attributes in Python and static attributes in Java or C++ have a lot in common, however, they have behavioral differences that I will highlight in this article.



from DZone.com Feed https://ift.tt/2IJjLvi

No comments:

Post a Comment