instance attribute
An attribute stored on one instance, usually set as self.name = value, so each instance has its own copy.
In more detail
Assigning to self.x in any method creates or updates it for that instance only. Reading self.x falls back to the class attribute if the instance has none.
Related terms
- class attribute — An attribute defined in the class body, shared by every instance of the class.
- attribute — A named value attached to an object and reached with a dot, such as point.x or math.pi; methods are attributes too.
- self — The name, by convention, of a method's first parameter, which receives the instance the method was called on.
Taught in
- Methods, Attributes And self — Hands-on Python: Complete Video Course & Book
- Classes, Objects And Two Stacks — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Class Variables, Instance Variables And __dict__ — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Object-Oriented Sprint — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Twelve Traps, Mostly Objects — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep