Mar-14-2024, 04:41 PM
A dictionary will not save information after the program ends. To do that you need files. Either a file you write yourself, or a file that is maintained by a database.
Dataclasses are just a convenient way for writing classes that mostly store information. By using @datacass you get __str__ and __repr__ methods that return prettier strings than those returned by Object. A dataclass can also alutomatically generate comparison methods (__lt__, __gt__, __eq__, etc) that you can use to compare or sort instances of your class. Other than thata, dataclasses are just like any other class. They are not capable of persistent storage.
You should read about json files.
Dataclasses are just a convenient way for writing classes that mostly store information. By using @datacass you get __str__ and __repr__ methods that return prettier strings than those returned by Object. A dataclass can also alutomatically generate comparison methods (__lt__, __gt__, __eq__, etc) that you can use to compare or sort instances of your class. Other than thata, dataclasses are just like any other class. They are not capable of persistent storage.
You should read about json files.