More Flexible Data Classes
00:00
More flexible data classes. So far, you’ve seen some of the basic features of the data class: it gives you some convenience methods, and you can still add default values and other methods. In this section, you’ll learn about some more advanced features, such as parameters to the @dataclass
decorator and the field()
function.
00:21 Together, they give you more control when creating a data class. Let’s return to the playing card example you saw at the beginning of the video course and add a class containing a deck of cards while we’re at it.
00:58 A simple deck containing only two cards can be created as seen next.
01:26 So now that we have what we need, in the next section, you’ll see how to create more advanced default values.
Become a Member to join the conversation.