[Tutor] Playing with generators
Mats Wichmann
mats at wichmann.us
Wed Aug 10 17:15:05 EDT 2022
On 8/10/22 15:00, Leam Hall wrote:
> After a few more initialization variables, the __init__ line will get
> pretty long. That's why I tend to use a data dict; I can keep the init
> line short, and deal with any missing variables in a way that best fits
> that variable.
there are tricks for this, but maybe for another time...
>
> I'm not using a dataclass, the goal is to learn generators. Things like
> dataclasses come later, when I know more of what the goal is.
a dataclass is just a regular class, except that the decorator generates
some stuff that's boilerplate so you don't have to - an __init__ that
assigns the args to attributes, an equals function (so you can compare
instances), and a string-representation function.
More information about the Tutor
mailing list