←back to thread

121 points _ZeD_ | 4 comments | | HN request time: 0.725s | source
Show context
nikisweeting ◴[] No.44539220[source]
I would donate $500 to the PSF tomorrow if they added this, the lack of it is daily pain
replies(3): >>44539245 #>>44540127 #>>44540364 #
IshKebab ◴[] No.44540127[source]
You shouldn't be using dicts for data that you know the name of anyway - use dataclasses or named tuples. Dicts are best for things with keys that are not known at compile time.
replies(1): >>44541834 #
1. IgorPartola ◴[] No.44541834[source]
Since when can you use data classes for kwargs? There are plenty of times when you should use a dict even if you know the keys.
replies(1): >>44542032 #
2. IshKebab ◴[] No.44542032[source]
You shouldn't be using kwargs! That is also well known to be bad practice (or it should be anyway).

https://medium.com/codex/stop-using-kwargs-as-method-argumen...

http://ivory.idyll.org/blog/on-kwargs.html

Give me another one.

replies(2): >>44542980 #>>44543391 #
3. almostgotcaught ◴[] No.44542980[source]
lol i think you didn't read/understand this - the article is about **kwargs (which is sometimes sloppy) while the person you're responding to is talking about "exploding" a dict when calling a function (this does not require **kwargs at all).
4. ahupp ◴[] No.44543391[source]
I’d agree with this, unless the kwargs is typed with the new-ish PEP-692: https://peps.python.org/pep-0692/