Skip to main content
Ctrl+K

Mastering Python

  • Learning Python
    • Your first Python application
    • Python Syntax
    • Variables and Types
    • Strings
    • Numbers
    • Booleans
    • Operators
    • Collections
    • Conditions
    • Functions
    • Loops
    • User Input
    • Exception handling
    • Working with Files
    • Modules
    • Classes
    • Iterators
    • JSON
    • Regular Expressions
    • Packages and virtual environments
  • Blog

Posts tagged field

How to use post-init with dataclasses

  • 12 October 2023
  • Editor
  • Language
  • dataclass init post-init field dataclasses

By default a class in Python has an __init__ method that is called when the class is instantiated. This method is used to initialize the class attributes. The example below shows this in action and how a variable is set by combining two other variables.

Read more ...


By Editor

© Copyright 2025, Mastering Python.