Python objects+classes

damomaja's version from 2015-10-08 04:32

Word drills 1

Question Answer
classTell Python to make a new type of thing.
objectTwo meanings; the most basic type of thing, and any instance of some thing.
instanceWhat you get when you tell Python to create a class.
defHow you define a function in a class.
selfInside the functions in a class, self is a variable for the instance/object being accessed.

Word drills 2

Question Answer
inheritanceThe concept that one class can inherit traits from another class, much like you and your parents.
compositionThe concept that one class can be composed of other classes as parts, much like how a car has wheels.
attributeA property classes have that are from composition and are usually variables.
is-aA phrase to say that something inherits from another, as in a "salmon" is-a "fish".
has-aA phrase to say that something is composed of other things or has a trait, as in "a salmon" has-a "mouth".