Roy Smith於 2013年4月25日星期四UTC+8上午7時50分33秒寫道: > I discovered something really neat today. > > > > We've got a system with a bunch of rules. Each rule is a method which > > returns True or False. At some point, we need to know if all the rules > > are True. Complicating things, not all the rules are implemented. > > Those that are not implemented raise NotImplementedError. > > > > We used to have some ugly logic which kept track of which rules were > > active and only evaluated those. > > > > So, here's the neat thing. It turns out that bool(NotImplemented) > > returns True. By changing the unimplemented rules from raising > > NotImplementedError to returning NotImplemented, the whole thing becomes: > > > > return all(r() for r in rules)
Problems of rules in Boolean algebra or the bi-level logic inference engine in AI were all solved long time ago in the text book about AI. There are some variations about the multi-level or the continuous level logic engine with some new phases in Fuzzy theory in the expert system. A dynamical typed language is better to be used in this kind of problems. -- http://mail.python.org/mailman/listinfo/python-list