That code as written will just use one dict_sub and keep replacing the
values in it, storing a reference to dict_sub for every dict[key]. So
I'm not surprised you're getting duplicated items. They should all be
duplicated. You can put dict_sub = {} inside the loop and it'll behave
like you expect.

If you want to do unique by the sub-items' values (and not just the
keys), how about creating the dicts like this instead? (Also, calling
it dict isn't good because it shadows the dict() function and isn't
very informative, so I'll call it marbles.)

marbles = {}
unique_values = {'subid1': {}, 'subid2': {}, 'subid3': {}}
for item in items:
    # ... get item's values and key
    sub = {'subid1': value1, 'subid2':, value2, 'subid3': value3}
    unique = True
    for k, v in sub.items():
        if v in unique_values[k]:
            unique = False
            break
        else:
            unique_values[k][v] = True
    if not unique:
        return
    marbles[key] = sub

Hope this helps.
--Nick
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to