Flashcards
Ex 41
Flashcards do conjunto (16)
- 1classTell Pyhton to make a new kind of thing
- 2objectThe most basic kind of thing
Any instance of some thing - 3instanceWhat you get when you tell Python to create a class
- 4defHow you define a function inside a class
- 5selfInside the functions in a class, self is a variable for the instance/object being accessed
- 6inheritanceThe concept that one class can inherit traits from another class
- 7compositionThe concept that a class can be composed of other classes as parts
- 8attributeA property classes have that are from composition and are usually variables
- 9is-aA phrase to say something inherits from another
- 10has-aA phrase to say something is composed of other things or has a trait
- 11class X (Y)"Make a class named X that is a Y"
- 12class X (object): def __init__(self, j)"Class X has-a __init__ that takes self and j as parameters"
- 13class X (object): def M (self, j)"Class X has-a function named M that takes self and j as parameters"
- 14foo = X ()"Set foo to an instance of class X"
- 15foo.M(j)"From foo get the M function, and call it with parameters self and j"
- 16foo.K = Q"From foo get K attribute, and set it to Q"
Informações
- Descrição
- Learn Python the Hard Way FlashCards sobre Ex 41, criado por Bruno Miguel Cretu em 29-10-2016.
- Criado por
- Bruno Miguel Cretu
- Visualizações
- 0
- Avaliação