On 3/18/2011 10:24 AM, Martin De Kauwe wrote:

def bounds_check(state):
     """ check state values are>  0 """
     for attr in dir(state):
         if not attr.startswith('__') and getattr(state, attr)<  0.0:
             print "Error state values<  0: %s" % (attr)

dir() has to do a bit a computation. I would be tempted to give 'state' a set of attributes to check. Call it 'nonnegatives'.
   for attr in nonnegatives:
      if ...

This allows for attributes not subject to that check.

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to