Classes and instances
A class defines behavior and attributes for its instances. __init__ initializes a newly created instance’s state; self refers to the instance receiving a method call. Different instances should have independent per-instance data. A method can read and update that state or compute a result from it according to a documented contract. Reading("api",80) and Reading("worker",40) should retain different names and values; changing one instance’s value should not automatically change the other instance’s stored state in this small model. Bundling related state and behavior makes repeated operations on the same entity clearer and helps prevent passing mismatched identifiers and values between unrelated functions as an application grows beyond its first simple prototype. Putting mutable per-instance state in a class-level list shares it across instances; initialize instance collections inside __init__ unless shared state is explicitly intended and documented as part of the class’s actual design contract.
Reading("api",80) and Reading("worker",40) should retain different names and values; changing one instance’s value should not automatically change the other instance’s stored state in this small model.Bundling related state and behavior makes repeated operations on the same entity clearer and helps prevent passing mismatched identifiers and values between unrelated functions as an application grows beyond its first simple prototype.
Putting mutable per-instance state in a class-level list shares it across instances; initialize instance collections inside __init__ unless shared state is explicitly intended and documented as part of the class’s actual design contract.