Vivek D. Hazari

Lexical Scoping in Python

· Vivek H.

A closure is stored as a variable (tuple of cell objects)

  • What would you expect to occur naively?

What about in another familiar language, like java script?

How can you make this work?

Default parameters, where you fill in a value

Why does this work?

  • Functions are also python objects! So, when you pass a default parameter, a copy of it at runtime becomes associated with the function object.
  • what if the object is a list of lists?
    • Does a default parameter make a deep copy?
      • to do: run this experiment.