[Tutor] two questions..

Israel Evans israel@lith.com
Wed, 14 Nov 2001 17:00:56 -0800


Thanks!

Talking about this, or at least attempting to describe these sorts of things
to other people really helps the brain!

-----Original Message-----
From: Kirby Urner [mailto:urnerk@qwest.net]
Sent: Wednesday, November 14, 2001 4:48 PM
To: Israel Evans
Cc: [tutor]
Subject: RE: [Tutor] two questions..



>
>Could this be done by having the regular calculations for body weight look
>for any modifier thingamabobs and if it found some, factor that into the
>calculations, and if not, then just do the calculations as normal?

Sure, why not?

  >>> class Body:
         def __init__(self):
             self.modifiers = {}  # define thingamabobs here


  >>> b = Body()
  >>> b.modifiers
  {}
  >>> b.modifiers['fat content'] = 20
  >>> class Process:

         def checkfat(self, body):
            bmods = body.modifiers
            if 'fat content' in bmods:  # fat checker
                 if bmods>15:
                    print "Sorry, too fat"
            else:
                print 'OK, normal'      # default even if no value


  >>> p = Process()
  >>> p.checkfat(b)
  Sorry, too fat
  >>> b2 = Body()
  >>> p.checkfat(b2)  # b2 has no fat content thingamabob
  OK, normal

Kirby