Dataclasses & What are they for - Deepstash

Dataclasses & What are they for

Dataclasses & What are they for

Dataclasses & What are they for

Dataclasses are an implementation of a code generator, similar to a Named Tuple.

The idea of using a code generator is to save time and reduce wordiness.

There are two views about the purpose of Dataclasses:

  1. It makes a mutable data holder, in the spirit of named tuples
  2. It writes boiler-plate code for you, simplifying the process of writing the class

These 2 world views are reflected in the name: “Dataclasses”

Per the dataclasses PEP, they are roughly a “Mutable named tuple with defaults”

They provide an elegant syntax for creating data holder objects

5

25 reads

It's time to

READ

LIKE

A PRO!

Jump-start your

reading habits

, gather your

knowledge

,

remember what you read

and stay ahead of the crowd!

It takes just 5 minutes a day.


TRY THE DEEPSTASH APP

+2M Installs

4.7 App Score