If mutable object is passed to a function and locally mutated, the change is preserved in the
global object
-
Functions and mutability:
Parameters = name that appear in a function definition
-
Arguments = values passed to a function when calling
-
Parameters can be given default arguments
-
Default arguments must follow non
default arguments
-
Arguments can be matched to parameters by position or by parameter names
-
Parameters and arguments:
Faster
-
Returning early:
A namespace is a mapping from names to objects
-
Global namespace in Python
-
Local namespace is called when function is called and forgotten after the function ends
-
Scope is the area of Python code where a particular namespace is used
-
Python first looks in the local namespace, then enclosing function namespaces and then in the
global namespace
-
Namespaces
Week 6
Sunday, 15 April 2018 6:42 PM
Foundations of Computing Page 1
Unlock document

This preview shows half of the first page of the document.
Unlock all 1 pages and 3 million more documents.

Already have an account? Log in

Document Summary

If mutable object is passed to a function and locally mutated, the change is preserved in the global object. Parameters = name that appear in a function definition. Arguments = values passed to a function when calling. Arguments can be matched to parameters by position or by parameter names. A namespace is a mapping from names to objects. Local namespace is called when function is called and forgotten after the function ends. Scope is the area of python code where a particular namespace is used. Python first looks in the local namespace, then enclosing function namespaces and then in the global namespace.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents