# Misunderstanding Python Class Attributes

DevFeed: [Misunderstanding Python Class Attributes](<https://devfeed.tech/articles/misunderstanding-python-class-attributes-32235.md>)

Original publisher: [Read original article](<https://bruceeckel.com/2022/05/11/misunderstanding-python-class-attributes/>)

Author: Bruce Eckel

Published: 2022-05-11T00:00:00Z

Content type: article

Language: en

Sources: [Bruce Eckel - Computing Thoughts](<https://devfeed.tech/sources/bruce-eckel-computing-thoughts.md>)

Topics: [Python](<https://devfeed.tech/topics/python.md>), [Code](<https://devfeed.tech/topics/code.md>), [Open Source](<https://devfeed.tech/topics/open-source.md>)

Tags: [class](<https://devfeed.tech/tags/class.md>), [code](<https://devfeed.tech/tags/code.md>), [open-source](<https://devfeed.tech/tags/open-source.md>), [python](<https://devfeed.tech/tags/python.md>)

## AI overview

This article explains a common misunderstanding about Python class attributes. It shows that assigning to an attribute through an instance creates or updates instance-specific storage, while class attributes provide shared class-level storage and can serve as defaults when accessed through an instance.

## Source excerpt

I was attempting to assist on an open-source project when I was stopped short by this (names have been changed): class DataPoint: measurement1 = None measurement2 = None measurement3 = None DataPoint was later used like this: d = DataPoint() d.measurement1 = 100 d.measurement2 = 200 d.measurement3 = 300 Why give names and initialization values to class attributes, then when you make an object, immediately create and initialize instance variables with the same names as the class attributes?