Why is it that *dbm modules don't provide an iterator? (Language design question)

Akira Kitada akitada at gmail.com
Thu Apr 9 23:39:03 CEST 2009


keys() returns a list and my question was not about "how to" but more
like "why"...
I assumed there were some decisions behind this, rather than it's just
not implemented yet.

Best,
On Friday, April 10, 2009, Joshua Kugler <joshua at joshuakugler.com> wrote:
> Akira Kitada wrote:
>
>> The loop has to be:
>> """
>>>>> k = d.firstkey()
>>>>> while k != None:
>> ...    print k
>> ...    k = d.nextkey(k)
>> key2
>> key1
>> """
>
> Why not
>
> for key in d.keys():
>     print key
>
> That worked for me.
>
> j
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list