Closed yhamoudi closed 9 years ago
It's really strange. I can access n.predicate
(print(n.predicate)
works) but not change it
So how can i do? I need to rebuild all the normal form?
Yes.
Mutable tree generally are not a good idea, unless you want to spend a lot of time debugging weird bugs.
ok.
Let's imagine i have a node n
whose type belongs to (List,Intersection,Union,And,Or,Last,First,Exists)
. I would like to build a normal form identical to n
except that n.list
contains one new element a
.
I could split this task:
if isinstance(n,List):
return List(n.list+[a])
elif isinstance(n,Intersection):
return Intersection(n.list+[a])
...
Is there a way to do this quicker?
Finally, i've done:
if isinstance(n,(List,Intersection,Union,And,Or,Last,First,Exists)):
return type(n)(n.list+[a])
I try to change the predicate of a
Triple
noden
by doing:n.predicate = ...
. However i obtain the errorAttributeError: 'Triple' object has no attribute 'predicate'
You can reproduce the error using the file
demo8.py
(indemo
folder) and the questionWho am i