for in sequence problem... possible new operator to add to python

Adam Gent agentgt at yahoo.com
Fri Jul 11 13:23:27 EDT 2003


Peter Hansen <peter at engcorp.com> wrote in message news:<3F0D95E6.3BC763D3 at engcorp.com>...

> 
> When you iterate over a dict in recent versions of Python, you 
> are by definition iterating over the keys in the dict.  If you
> want the values, you use .values(), and if you want both keys
> and values, you use .items().  See the docs for more.
> 
> -Peter

I wanted my dict to imitate a list... just for fun. A listdict if you
will. The only problem is that if you pass my listdict to code that
expects a true list  "for x in b" will break.
I did not know about __iter__(). Thanks for informing me.
__iter__ is not explained in
http://www.python.org/doc/current/lib/module-operator.html
shouldn't it be there?




More information about the Python-list mailing list