Names:
- Every name → contains a value → a reference to the address of an object
- Search names in order:
innermost scope(function body, usually) local
↓
enclosing scopes nonlocal
↓
global(current module or __main__)
↓
built-in names
http://docs.python.org/3.3/tutorial/classes.html#python-scopes-and-namespaces
Methods:
The first parameter, conventionally called self, is a reference to the instance:
e.g. >>> class Foo:
... def f(self):
... return "Hi world!"
...
>>> f1 = Foo()
So now Foo.f(f1) means f1.f()
Tracing:
Recommended:
- Tracing the simplest(non-recursive) case
- Tracing the next-most complex case, plug in known results
- Same as previous step
Use Visualizer!
No comments:
Post a Comment