fork download
  1. from dataclasses import dataclass
  2. from dataclasses import field
  3.  
  4. @dataclass
  5. class Example:
  6. a: int
  7. b: int
  8. c: int = field(default=-2)
  9.  
  10. print(Example(1, 2).c) # prints -1
  11. print(Example(1, 2, 3).c) # prints 3
Success #stdin #stdout 0.27s 19172KB
stdin
Standard input is empty
stdout
-2
3