I&C SCI 33 Lecture Notes - Lecture 2: Function Object, Special Functions
Document Summary
Functions: defining a function f refers to a function, defining g = f would make g refer to the same function that f refers to, names are represented in diagrams by boxes. Binds names to objects: names always refer to objects in python, you can loop through lists/dictionaries of functions (making references to those functions), and call those functions. Function calls returning references to function objects: def bigger_than(v): def test(x): return x > v return test, calling x = bigger_than(5) sets v = 5, then if you call x(6) you will get a value of true. Functions vs. methods: recall: a method call is a special function call. In python, you can do x, y = y, x. Python computes all the expressions/objects on the right and binds the names on the left to these values/objects (bind x to 2 then y to 1) Aka sequence unpacking assignment l, m, (n, o) = (1, 2, [3, 4])