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

2009-04-11 Thread Akira Kitada
Opened a ticket for this and attached a patch. (experimental) http://bugs.python.org/issue5736 On Fri, Apr 10, 2009 at 8:39 AM, "Martin v. Löwis" wrote: I assumed there were some decisions behind this, rather than it's just not implemented yet. >>> I believe this assumption is wrong - i

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

2009-04-09 Thread Martin v. Löwis
>>> I assumed there were some decisions behind this, rather than it's just >>> not implemented yet. >> I believe this assumption is wrong - it's really that no code has been >> contributed to do that. > > But doesn't the issue at http://bugs.python.org/issue662923 imply that > there *was* suitable

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

2009-04-09 Thread andrew cooke
"Martin v. Löwis" wrote: >> I assumed there were some decisions behind this, rather than it's just >> not implemented yet. > > I believe this assumption is wrong - it's really that no code has been > contributed to do that. But doesn't the issue at http://bugs.python.org/issue662923 imply that the

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

2009-04-09 Thread Martin v. Löwis
> I assumed there were some decisions behind this, rather than it's just > not implemented yet. I believe this assumption is wrong - it's really that no code has been contributed to do that. For gdbm, you can also use the firstkey/nextkey methods. Regards, Martin -- http://mail.python.org/mailma

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

2009-04-09 Thread skip
Joshua> Why not Joshua> for key in d.keys(): Joshua> print key Joshua> That worked for me. Time & space. One motivation for using dbm files is to write large (huge, in fact) mappings to disk. Simply reconstituting the entire set of keys may consume a lot of time (they must

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

2009-04-09 Thread Akira Kitada
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 wrote: > Akira Kitada wrote: > >> The loop has to be: >> """ > k = d.f

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

2009-04-09 Thread Joshua Kugler
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

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

2009-04-09 Thread Akira Kitada
Hi, I was wondering why *dbm modules in Python do not give us an iterable interface? Take a look at an example below """ # Python 2.6 >>> import gdbm >>> d = gdbm.open("spam.db", "n") >>> d["key1"] = "ham" >>> d["key2"] = "spam" >>> >>> for k in d: ... print k ... Traceback (most recent call