Table des matières

Programmation Python Orientée Objet

FIXME : en construction

Concepts utilisés

intro-OO-01.py3
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
""" 
Introduction to object-oriented programming in Python
 
Led with number and status attributes
"""
class Led:
    def __init__(self, number, status):
        self.number = number
        self.status = status
    def on(self):
        self.status = 'on'
    def off(self):
        self.status = 'off'
 
led1 = Led(1, 'on')
print(led1)
print(type(led1))
print(type(Led))
print(led1.number)
print(led1.status)

Références