Python 3.7 – data classes

A cool new feature made its way into Python 3.7: Data classes.

When You’ve already read my article about Lombok the concept isn’t so new at all: With the new decorator @dataclass You can save a huge amount of time because the methods

  • __init__()
  • __repr__()
  • __eq__()

are created for you!

from dataclasses import dataclass

class CinemaEvent:
    location: str
    url: str

my_event = CinemaEvent("Cinecitta", "")

Further readings: