How do I pass a variable by reference?

Arguments are passed by assignment. The rationale behind this is twofold: the parameter passed in is actually a reference to an object (but the reference is passed by value) some data types are mutable, but others aren’t So: If you pass a mutable object into a method, the method gets a reference to that same object and you can mutate … Read more

What does ** (double star/asterisk) and * (star/asterisk) do for parameters?

The *args and **kwargs is a common idiom to allow arbitrary number of arguments to functions as described in the section more on defining functions in the Python documentation. The *args will give you all function parameters as a tuple: The **kwargs will give you all keyword arguments except for those corresponding to a formal parameter as a dictionary. Both idioms can be mixed with normal arguments to … Read more