COMPSCI 61A Lecture Notes - Lecture 17: Init, Message Passing, Return Ratio

60 views6 pages
zogo39484755 and 6 others unlocked
COMPSCI 61A Full Course Notes
22
COMPSCI 61A Full Course Notes
Verified Note
22 documents

Document Summary

Object value should behave like the kind of data it is meant to represent. For instance, by producing string representation of itself. Strings are important: they represent language and programs. In python, all objects produce two string representations: Str and repr strings are often the smae, but not always. Repr func returns a python expression (a string) that evaluates to an equal object. Returns canonical string representation of the obejct, for most object types, eval(repr(object)) == object. Result of calling repr on a value is what python prints in an interactive session. Some objects do not have a simple python readable string. Human interpretable strings are useful as well: Gives back value that is human interpretable representation of string. Result calling str on value of an expressino is what python prints using the print fucntino: Polymorphic function:function that applies to many )poly) different forms(morph) of data. Str and repr are both polymorphic; they apply to any object.

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
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents