Sorry, I am re-posting my question in the correct format python code.
I have two python objects namely aObj, and bObj.
They both have the same attributes as following:
I do not know why it gave me the error. So I would be appreciated if you could help.
Thanks!
I thought I may have its working by having the following:
I have two python objects namely aObj, and bObj.
They both have the same attributes as following:
{'name': 'a', 'attributes': {'shape': 'diamond', 'size': 'very small', 'fill': 'yes'}} {'name': 'b', 'attributes': {'shape': 'diamond', 'size': 'very small', 'fill': 'yes'}}I tried to do a string comparison between aObj and bObj on the attribute size such as:
for aObjName in self.sortDict(a.objects): aObj = a.objects[aObjName] for bObjectName in self.sortDict (b.objects): bObj = b.objects[bObjectName] if aObj.attributes['shape'] == bObj.attributes['shape']: transformDict ['Shape'] = aObj.attributes['shape'] + '-' + bObj.attributes['shape'] print ('Shape ' + transformDict ['Shape']) if aObj.attributes['fill'] == bObj.attributes['fill']: transformDict['Fill'] = aObj.attributes['fill'] + '-' + bObj.attributes['fill'] print ('Fill ' + transformDict ['Fill']) if aObj.attributes['size'] == bObj.attributes['size']: print ("two objects are the same");I then got a Key error on ['size']. It worked fine on shape and fill attributes. Just did not work on attribute size for some unknown reason.
I do not know why it gave me the error. So I would be appreciated if you could help.
Thanks!
I thought I may have its working by having the following:
if "size" in aObj.attributes and "size" in bObj.attributes: if aObj.attributes['size'] == bObj.attributes['size']: print ("size no change between aObj and bObj") else: print ("Size changed between aObj and bObj")