COMP 305 Study Guide - Midterm Guide: Init, Duck Typing, Template Method Pattern

65 views3 pages

Document Summary

In class" namespace to be shared by instances. # creates an instance attribute for additional attributes the user provides. Dictionary is the best way of representing a polynomial - no searching or scanning. We can make an instance of a class callable by providing a method name: __call__ Want to use instances as functions add __call__ Magic methods are hooks - methods like __func__ Creates an object but have no idea what you are producing. # returns class and arguments provided def new(obj, *args, **kw) : Factoring , such as factoring the template method intersect into the superclass. Contains yield ; creates a generator object which is an iterator. An iterator of a container lines up the elements to allow visitation of all the elements. The best iterators are those generated by generator functions. Process(x) python container c just call iter(c) (2)__next__() raises a "stopiteration" exception when there are no more elements to visit.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related Documents