Sahaj.blogs

Day page

18 Sept 2023

Study

Python · Functions: *args, **kwargs and scope

Variable-length arguments with *args and **kwargs, keyword-only parameters, unpacking at the call site, and LEGB scope.

  • *args collects extra positional arguments into a tuple; **kwargs collects extra keyword arguments into a dict.
  • Python looks names up in the order Local, Enclosing, Global, Built-in.

Read the post →