Pass arguments by reference in Python

Pass arguments by reference—in Python! byrefis a decorator that allows Python functions to declare reference parameters, with similar semantics to C++’s T& or C#’s ref T. Any modifications made within the function to these parameters will be picked up by the caller. Usage from byref import byref @byref(“x”) def add(x, y, /): x += y a = 60 add(a, 40) print(f”{a}!”) # this prints 100! Motivation I thought it would be funny.

Read more