On Mon, Sep 17, 2012 at 3:42 AM, Albert-Jan Roskam <fo...@yahoo.com> wrote:
>
> Another idea would be to also use __getitem__ as a dictionary. So when
> the data contains an id (let's say ssn), r = Reader(key="ssn");
> r.data["87654321"] returns the corresponding (first available) record.
> But although this is cool from an educational perspective, I do wonder
> whether, from a design perspective, it's a good idea to make __getitem__
> this fully packed.

Maybe have a mappingview() method that returns a lazy mapping view of
the object. That way you're not mixing up indexed and mapping
subscription.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to