Example:
class Bird:
def __init__(self):
self.sound = "chirp!"
def reproduce_sound(self):
if self:
print(self.sound)
bird = Bird()
bird.reproduce_sound()
What does if self: mean? What is the case where the reproduce_sound function call prints nothing?
Aucun commentaire:
Enregistrer un commentaire