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

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

anthonywritescode

anthonywritescode

Күн бұрын

Пікірлер: 7
@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
Unpacking Operators in Python: What are * and **?
12:35
NeuralNine
Рет қаралды 10 М.
Что-что Мурсдей говорит? 💭 #симбочка #симба #мурсдей
00:19
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН
WHAT are *args & **kwargs in Python?
7:35
Indently
Рет қаралды 6 М.
debugging a broken cache!
21:16
anthonywritescode
Рет қаралды 4 М.
Python *ARGS & **KWARGS are awesome! 📦
14:54
Bro Code
Рет қаралды 86 М.
*Args and **Kwargs in Python
3:49
b001
Рет қаралды 291 М.
debugging and fixing pyuwsgi in python 3.12 (advanced) anthony explains #580
1:00:01
how does python's module `__getattr__` actually work?
17:38
anthonywritescode
Рет қаралды 6 М.
oops I'm the pyuwsgi maintainer now (intermediate) anthony explains #579
22:55
Every Programming Language Ever Explained in 15 Minutes
15:29
Flash Bytes
Рет қаралды 361 М.