Set of Dictionary
Konstantin Veretennicov
kveretennicov at gmail.com
Thu Jun 16 14:21:50 EDT 2005
On 6/16/05, Vibha Tripathi <vibtrip at yahoo.com> wrote:
> I need sets as sets in mathematics:
That's tough. First of all, mathematical sets can be infinite. It's
just too much memory :)
Software implementations can't fully match mathematical abstractions.
> sets of any unique type of objects including those
> of dictionaries, I should then be able to do:
> a_set.__contains__(a_dictionary) and things like that.
Maybe you can use a list for that:
>>> d1 = {1: 2}
>>> d2 = {3: 4}
>>> s = [d1, d2]
>>> {1: 2} in s
True
>>> {5: 6} in s
False
> Can sets in Python 2.4.1, be reimplemented from
> scratch to not have it work on top of dict?
Sure, why not?
- kv
More information about the Python-list
mailing list