Loading...
「ツール」は右上に移動しました。
利用したサーバー: natural-voltaic-titanium
0いいね 23回再生

Python dataclass intro: hockey player example

In this video we revisit an example of a simple class "encapsulating" some properties and methods pertaining to a hockey player. This time we imported the "dataclass" module and "decorated" the class as a dataclass. We then noted some of the work that this procedure took care of for us. It generated an _init_ method (constructor) for us. It generated a _repr_ (representation) method for us. It generated a compare method for us. We also imported field along with dataclass, and this feature allowed us to specify if a field was to be included in the constructor, to be used in compare (when testing for equality), and so on.

コメント