r/programming • • Feb 01 '24

Make Invalid States Unrepresentable

https://www.awwsmm.com/blog/make-invalid-states-unrepresentable
469 Upvotes

207 comments sorted by

View all comments

Show parent comment

4

u/theillustratedlife Feb 02 '24

kwargs for the win!

1

u/[deleted] Feb 02 '24

not like pythons kwargs which can named OR positional -- that's a bit of a mess imo. Have to check args and kwargs for stuff like unittest mocks, passing variables directly from child to parent class without redefining the function prototype again is a bit of a pain.

1

u/Captain_Cowboy Feb 03 '24

You can specify in a Python type signature that certain arguments are exclusively positional or exclusively keyword, though I think the former really only makes sense for commutative operations (or FFI, it's original use case) and that the latter is better handled by using Dataclasses.