mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
Changed way of creating classes
This commit is contained in:
parent
aad7eb82dd
commit
097c839b7b
@ -570,8 +570,8 @@ filter(lambda x: x > 5, [3, 4, 5, 6, 7]) # => [6, 7]
|
||||
####################################################
|
||||
|
||||
|
||||
# On hérite de object pour créer une classe
|
||||
class Human(object):
|
||||
# On utilise l'opérateur "classe" pour définir une classe
|
||||
class Human:
|
||||
|
||||
# Un attribut de la classe. Il est partagé par toutes les instances de la classe.
|
||||
species = "H. sapiens"
|
||||
|
@ -569,8 +569,8 @@ filter(lambda x: x > 5, [3, 4, 5, 6, 7]) # => [6, 7]
|
||||
####################################################
|
||||
|
||||
|
||||
# We subclass from object to get a class.
|
||||
class Human(object):
|
||||
# We use the "class" operator to get a class
|
||||
class Human:
|
||||
|
||||
# A class attribute. It is shared by all instances of this class
|
||||
species = "H. sapiens"
|
||||
|
Loading…
Reference in New Issue
Block a user