From 256cd3e4ca935102fd0898d1d17ed34b1202903e Mon Sep 17 00:00:00 2001 From: LtWorf Date: Tue, 28 Apr 2009 20:39:10 +0000 Subject: [PATCH] now using isinstance instead of that ugly thing git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@133 014f5005-505e-4b48-8d0a-63407b615a7c --- relational/optimizer.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/relational/optimizer.py b/relational/optimizer.py index 3e67024..9b457a2 100644 --- a/relational/optimizer.py +++ b/relational/optimizer.py @@ -33,10 +33,10 @@ class node (object): def __init__(self,expression): '''Generates the tree from the tokenized expression''' - while len(expression)==1 and expression[0].__class__==[].__class__: #We have a list, removing + while len(expression)==1 and isinstance(expression[0],list): #We have a list, removing expression=expression[0] - if len(expression)==1 and expression[0].__class__=="".__class__: #We have a string! + if len(expression)==1 and isinstance(expression[0],str): #We have a string (relation name) print "Relation: ",expression[0] self.kind=RELATION self.name=expression[0] @@ -168,6 +168,11 @@ def tree(expression): #isinstance(k,list) return node(tokenize(expression)) +def optimize(expression): + n=tree(expression) #Gets the tree + + return n.__str__() + if __name__=="__main__": #n=node(u"((a ᑌ b) - c ᑌ d) - b") #n=node(u"((((((((((((2)))))))))))) - (3 * 5) - 2")