python: typing *args / **kwargs (intermediate) anthony explains

  Рет қаралды 1,858

anthonywritescode

anthonywritescode

Күн бұрын

Пікірлер
@akshaymestry971
@akshaymestry971 3 жыл бұрын
Thanks for this Anthony!! This gave some insight for type hinting *args and **kwargs!
@erwan5112
@erwan5112 4 жыл бұрын
This means less libraries exposing `some_func(*args:Any, **kwargs: Any) -> Any` which wraps a function which wraps a function where arguments are finally defined? Amazing! Last time I ended up redefining the API subset I was using: def typed_wrapper( arg1: str, arg2: int, arg3: Tuple[str, str] ) -> int: kwargs = rebuild_kwargs(locals()) return untyped_function(**kwargs) With this to rebuild kwargs: gist.github.com/tools4origins/e1962a9edb3734ad47f5e5ca7be34697
@anthonywritescode
@anthonywritescode 4 жыл бұрын
that function looks a bit scary! why not just `**locals()` at that point (or I guess that would limit you based on the assignments in the rest of the function)
@erwan5112
@erwan5112 4 жыл бұрын
🤯 it does work in most cases indeed
@esparafucio
@esparafucio Жыл бұрын
I'm still struggling to understand the syntax exactly, say I have a class from a module: class MyClass(module.Class): def __init__(self, *args: Any, **kwargs: Any): super.__init__(*args, **kwargs) How would I annotate that to avoid Any?
@sillybuttons925
@sillybuttons925 4 жыл бұрын
when you can't pass mypy.......
@sillybuttons925
@sillybuttons925 4 жыл бұрын
#ANY
oops I'm the pyuwsgi maintainer now (intermediate) anthony explains #579
22:55
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН
Python *ARGS & **KWARGS are awesome! 📦
14:54
Bro Code
Рет қаралды 86 М.
debugging and fixing pyuwsgi in python 3.12 (advanced) anthony explains #580
1:00:01
Unpacking Operators in Python: What are * and **?
12:35
NeuralNine
Рет қаралды 10 М.
*Args and **Kwargs in Python
3:49
b001
Рет қаралды 291 М.
WHAT are *args & **kwargs in Python?
7:35
Indently
Рет қаралды 6 М.
Google’s Quantum Chip: Did We Just Tap Into Parallel Universes?
9:34
debugging a broken cache!
21:16
anthonywritescode
Рет қаралды 3,9 М.
Optional Arguments in Python With *args and **kwargs
10:44
Real Python
Рет қаралды 125 М.
But what are Python *ARGS & **KWARGS?
7:39
CodingEntrepreneurs
Рет қаралды 90 М.