On Sun, May 12, 2019 at 10:14 AM Ricky Teachey <ri...@teachey.org> wrote:
>
> Using iter() for the sole purpose of being able to shoehorn your user class 
> into being dict-cast-able is, IMO, an abuse of iter.
>
> If your class makes logical sense as an iterable of key/value pairs, then for 
> petesake, just use the mapping protocol (implement getitem and keys). iter() 
> is for constructing sequences, not mappings.
>

iter() is for collections of all sorts; a sequence is specifically an
ordered and indexed collection, but you can iterate over many things,
including sets - and mappings. There's nothing wrong with iterable
mappings, and in fact, I would be surprised (and not in a good way) by
any that wasn't.

ChrisA
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to