[Tutor] OK, dumb question
K P
teroc@zianet.com
Mon, 7 Jun 1999 16:49:59 -0500
-------Phoenix-Boundary-07081998-
Content-type: text/plain; charset=ISO-8859-1
Content-transfer-encoding: Quoted-printable
I seem to be stuck on the littlest of problems, how do I do this in Python:
iterate through a 'list' (term used loosely) of twelve class variables,
check each for changes
I know how to do this in C++, but for the life of me cannot make the
connection in Python. Here is an example(with my infamous spam):
class Meat:
def __init__(self, colour, type):
self.colour =3D colour
self.type =3D type
self.flavor =3D ' '
class Spam:
def __init__(self):
self.beef =3D Meat('red', 'beef')
self.chicken =3D Meat('white', 'fowl')
def quality(self):
#In this function I would check the type and colour versus a 'chart'
(probably a dictionary look-up)
#e.g. if self.beef.colour =3D 'red' and self.beef.type =3D 'beef'
then self.beef.flavor =3D 'good'
#In my 'real' script I would be testing 12-20 class member variables
against a small set of immutable variables
#what would be the simplest/fastest/most effective way to code that
in python=3F
Ken
-------Phoenix-Boundary-07081998---