On 26/04/2017 21:50, Chris Angelico wrote:
On Thu, Apr 27, 2017 at 6:24 AM, Erik firstname.lastname@example.org wrote:
The background is that what I find myself doing a lot of for private projects is importing data from databases into a structured collection of objects and then grouping and analyzing the data in different ways before graphing the results.
So yes, I tend to have classes that accept their entire object state as parameters to the __init__ method (from the database values) and then any other methods in the class are generally to do with the subsequent analysis (including dunder methods for iteration, rendering and comparison etc).
You may want to try designing your objects as namedtuples. That gives you a lot of what you're looking for.
Something like https://docs.python.org/3/library/sqlite3.html#row-objects ?