or cast to ``dict``, though i like the default factory one -- didn't
realize you could do that


On Mon, Dec 23, 2013 at 12:32 PM, Jai Ram Rideout
<notifications@github.com>wrote:

> In qiime/util.py:
>
> > +            all_sample_ids.add(sample_id)
> > +            for header, value in data.iteritems():
> > +                all_headers.add(header)
> > +                # if the two mapping files have identical sample_ids and
> > +                # metadata columns but have DIFFERENT values, raise a value
> > +                # error
> > +                if merged_data[sample_id][header] is not None and \
> > +                        merged_data[sample_id][header] != value:
> > +                    raise ValueError("Different values provided for %s for "
> > +                                     "sample %s in different mapping files."
> > +                                     % (header, sample_id))
> > +                else:
> > +                    merged_data[sample_id][header] = value
> > +
> > +        # Now, convert what we have seen into a normal dict
> > +        normal_dict = {}
>
> A more efficient and shorter way to make a defaultdict behave like a dict:
>
> merged_data.default_factory = None
>
> Then any lookups that don't exist will raise a KeyError as you'd expect.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/qiime/qiime/pull/1302/files#r8533076>
> .
>