[Tutor] defaultdict(set)
Kent Johnson
kent37 at tds.net
Fri Sep 26 03:13:31 CEST 2008
On Thu, Sep 25, 2008 at 7:35 PM, Dinesh B Vadhia
<dineshbvadhia at hotmail.com> wrote:
> I'm using defaultdict(set) to store a dictionary d = {value : set_items}
> where value = integer and set_items = set() of characters and it works
> perfectly.
>
> I would like to also store the length of the set ie. l = len(set_items) with
> the dictionary but don't how to do it using a defaultdict(). Any ideas?
Why not just take the length when you need it? There is no need to
store it separately. e.g. len(d[3])
Kent
More information about the Tutor
mailing list