Content
@
https://opensea.io/collection/dev-21
0 reply
0 recast
2 reactions
jtgi
@jtgi
I’m learning python after 10y of javascript and taking some notes
6 replies
0 recast
27 reactions
Señor Doggo
@fubuloubu
You don't need to add `*,` in function def to use named args (kwargs), you can just do that directly The `*,` syntax is a hack to actually use named args out of sequence (in the middle vs. at the end of the args), but that's more of an advanced technique You can use `*args` to collect all non-keyword args (or have a sequence), and you can use `**kwargs` to collect all keyword args
2 replies
0 recast
2 reactions
🥷
@roman
I use the * param to specify which parameters are required to be pass as named (the ones after the *) - super useful when args with similar types and meanings are next to each other. Also emphasizing the last paragraph, passing a **dict as argument set is a-mazing.
1 reply
0 recast
1 reaction
Señor Doggo
@fubuloubu
I love that feature, use it all the time BTW you can pass normal arguments as named kwargs e.g. `data=..., ` (but only if you remove the `*, ` I think)
1 reply
0 recast
0 reaction
Señor Doggo
@fubuloubu
Also want to caveat I rarely ever use `*, ` Only in FastAPI dependencies via typing where I need to do something like `route_name(..., query_arg=None, db: Database, ...) `
0 reply
0 recast
0 reaction