#!/usr/bin/python
# -*- coding: iso-8859-1 -*-
__version__ = "$Revision: 0.1 $"
__author__ = "Nicolas Seriot"
__date__ = "2005-03-27"
class Car:
"""
This class represents a Car
"""
# constructor
def __init__(self, brand, color):
self.brand = brand
self.color = color
# a method
def paint(self, color):
self.color = color
# string description
def __str__(self):
return self.brand + ", " + self.color
# destructor
def __del__(self):
pass
if __name__ == "__main__":
c1 = Car("Ford", "blue")
c2 = Car("Ferrari", "red")
cars = [c1, c2]
c2.paint("pink")
for c in cars:
print c
$ python cars.py
Ford, blue
Ferrari, pink