4 ms·
I have never seen that talk, I might check it out later though. >If a class has two methods and one of them is __init__ it doesn't need to be a class. That se
by hitpointdrew 4y ago
I have never seen that talk, I might check it out later though.
>If a class has two methods and one of them is __init__ it doesn't need to be a class.
That seems like dumb advice to me. I don't use classes often in Python, but when I do it is typically because I have a more complex data set to work with and I don't really need database. Usually this is a class that ONLY has an __init__ function in it. Having data set that is a dictionary with nested dictionaries, with nested arrays ,etc. gets ugly and often you end up with a mess of loops trying to parse the data. I find classes super helpful here and would just instance a bunch of class objects with attributes I need, then put all those objects in a list. You can then iterate over a nice, simple, clean, list of you objects and access any attribute you wish. Without having to do nested loops trying to dig down the the value you want.