[Grok-dev] Re: Iterativly emptying a grok.container shows weird
faassen at startifact.com
Tue Jun 12 15:09:08 EDT 2007
Dr. Volker Jaenisch wrote:
> Yesterday I noticed that the tutorial (which I like otherwise very much)
> lead me to program nonsense.
> Me as experianced programmer may find the error - the Enduser that GROK
> addresses may not.
The minimal thing we should do is to say this in the tutorial: keys() is
actually like iterkeys() in Python, etc, etc.
I think these are good arguments to not replace keys() with iterkeys()
in plain python. :)
I haven't seen the answer yet elsewhere in the thread, but perhaps I
didn't read it correctly. Anyway, the simplest way to make this work as
expected is to use 'list()':
for key in list(container.keys()):
We could also consider petitioning Zope 3 to modify the container APIs
and change the behavior of keys() to use list() internally, and adding
an iterkeys(). This wouldn't be hard to implement, but the repercussions
might be large for some applications, so we'd need to do this carefully.
I'd be happy to help discuss this on zope3-dev.
More information about the Grok-dev