COMP 305 Study Guide - Final Guide: Init, Idiom, Strategy Pattern

54 views8 pages

Document Summary

Class is used to store default values of instances. 90% are americans citizenship stored as a class level attribute (default) As a result, different instances often have different sets of attributes. Htmlelement would be a good place to store the write method. __call__ used to turn an instance into a callable object. Produce instances without knowing what instances you are producing. Can accomplish 20 lines in 1 line. All the elements of the container needs to be collected beforehand. Different ways to write a caching decorator. We must have a nested function (function inside a function). The nested function must refer to a value defined in the enclosing function. The enclosing function must return the nested function. Running setter and getter code w/o using java"s getter/setter syntax, i. e. obj. x = val can run setter code. Obj. x can run __getattr__ to prevent it from raising an exception. Simplest way of running getter and setter code.