Annotate args in Python with Type Hints

How to annotate *args in #Python? Just set the elements' type; we know it's a tuple: def mysum(*args:int) -> int: total = 0 for n in args: total += n return total Normally, tuples contain different types. In args, we assume all values have the same type.

  • No alternative text description for this image

How do you use *args and **kwargs in ParamSpec?

To view or add a comment, sign in

Explore content categories