All pastes #248991 Raw Edit

Cody Brocious

public python v1 · immutable
#248991 ·published 2006-11-15 07:25 UTC
rendered paste body
#!/usr/bin/env python# encoding: utf-8"""testBattery.pyCreated by  on 2006-11-14."""from interface import interfacefrom queryableModel import queryableModelclass pet(interface):    __public_attributes__ = ('name', 'age', 'species')        def __init__(self, name, age, species):        self.name = name        self.age = age        self.species = species        def __repr__(self):        return '%s named %s is %i years old' % (`self.species`, `self.name`, self.age)def testQueries():    testObj = queryableModel()    testObj.childAdd(pet('Daeken', 18, 'Human'))    testObj.childAdd(pet('Nikashera', 18, 'Neko'))    testObj.childAdd(pet('Joe Bob', 72, 'Human'))    testObj.childAdd(pet('Dean', 76, 'Human'))        print 'Humans:', testObj.query(lambda child: child.species == 'Human')    print '18 year olds:', testObj.query(lambda child: child.age == 18)    print 'Seniors:', testObj.query(lambda child: child.age > 65)testQueries()