MonkeeSage wrote: > Hi Saizan, > > I don't really see anything wrong with creating a custom class for > evaluating those kinds of logical statements. It does make the code for > statements more concise and easy to follow (with less binding > ambiguity). Mabye something like this would help: > > class logic(int): > def __sub__(self): > return logic(not self) > def eval(self, statement): > return bool(statement) > def make_logical(self, *args): > out = [] > for arg in args: > out.append(logic(arg)) > return out > > l = logic() > # init a buch of variables (or a list) at once > x, y, z = l.make_logical(True, False, True) > # or one at a time > v = logic(False) > # evaluate a statement > print l.eval((x and y) or (-z or -v)) # True > Is this a serious suggestion, or simply an attempt at sardonic obscurantism?
regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list