Learn Python

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

class X(Y)

Make a class named X that is-a Y

class X(object): def M(self, J)

class X has-a function that takes self and J parameters

is-a

A phrase to say that something inherits from another, as in a "salmon" is-a "fish."

has-a

A phrase to say that something is composed of other things or has a trait as in "a salmon has-a mouth."

attribute

A property classes have that are from composition and usually variables

class X(object): def __init__(self, J)

Class X has-a __init__ that takes self and J parameters

foo.K = Q

From foo get the K attribute and set it to Q.

foo.M(J)

From foo get the M function, and call it with parameters self, J.

def

How you define a function inside a class

self

Inside the functions in a class, self is a variable for the instance/object being accessed

foo = X()

Set foo to an instance of class X

class

Tell Python to make a new kind of thing.

composition

The concept that a class can be composed of other classes as parts, much like how a car has wheels

inheritance

The concept that one class can inherit traits from another class, much like you and your parents

object

Two means: the most basic kind of thing, and any instance of some thing

instance

What you get when you tell Python to create a class


Ensembles d'études connexes

Chapter 38: assessment and management of patients with rheumatic disorders

View Set

Az állam feladatai, az állam gazdasági szerepe

View Set

Chapter 2 Malware and Social Engineering Attacks

View Set