I've searched around and tried to .encode(...) the string, but I can't imagine this issues is as serious as it seems.
I have two datastructures, one is loaded from a YAML file, the other from a JSON file.
Both contents have been processed (I'm iterating over the data):
Dictionary of YAML
[{'SynID': 66, 'action': 'userInit', 'appLocation': 0},
{'SynID': 66, 'action': 'isEngager', 'appLocation': 0}]
Dictionary of JSON
{u'name': u'SynID', u'value': u'66'}
...
{u'name': u'action', u'value': u'isEngager'}
Finally, when doing the comparision, anything involving an integer (non string) fails. For example:
if uriDict['name'] in expectedResultsSubDict and uriDict['value'] == expectedResultsSubDict[uriDict['name']]:
Logger().l("[%s] Match: %s:%s == %s" % (pos, uriDict['name'], uriDict['value'], expectedResultsSubDict[uriDict['name']]))
elif uriDict['name'] in expectedResultsSubDict:
Logger().l("[%s] Name: %s, value: %s" % (pos, uriDict['name'], uriDict['value']))
The first if statement fails to match the key/value of SynID:66, but will match the second entry, action:isEngager.
2013-01-28 12:48:42,151 : DEBUG : [0] Name: SynID, value: 66
2013-01-28 12:48:42,151 : DEBUG : [0] Match: action:userInit == userInit
As you can see in the output, it doesn't match the SynID, but matches the action.
If I add in this line:
elif uriDict['name'] in expectedResultsSubDict and int(uriDict['value']) == int(expectedResultsSubDict[uriDict['name']]):
Logger().l("[%s] Int Match: %s:%s == %s" % (pos, uriDict['name'], uriDict['value'], expectedResultsSubDict[uriDict['name']]))
It will work properly on the SynID (and other field that have ints) but fail on the string fields. I also tried changing the '==' comparison to 'is', and in that case, nothing matched.
Q) How do I compare the values of my dictionary?