container-indepentent iteration code ?
flacco002 at spambadTwilight-systems.com
Thu Sep 9 02:35:56 CEST 2004
Jeremy Bowers wrote:
> On Wed, 08 Sep 2004 19:27:38 -0400, flacco wrote:
>>is there a way to iterate over the *values* in a list/dict/whatever,
>>regardless of whether it's a list, dict, or whatever? ie, the iteration
>>code will not know beforehand what kind of container it's getting.
> In what way does
> for obj in container:
> not meet your needs?
i always want obj to be the value. dicts, for example, yield keys
instead of values (i think?)...
More information about the Python-list