[Grok-dev] Re: Iterativly emptying a grok.container shows weird behavior

Dr. Volker Jaenisch volker.jaenisch at inqbus.de
Tue Jun 12 12:01:32 EDT 2007


Hello Philipp!

Philipp von Weitershausen schrieb:
>
> To our defence, we nowhere say that containers *are*
In the tutorial, one read:
 > From the perspective of Python, you can think of containers as 
dictionaries. They allow item access (container['key']) to get at its > 
contents. They also define methods such as keys() and values().

I think this formulation is misleading. I am an experianced programmer 
but the (very good made) tutorial lead me to code this nonsense.

To be constructive. Why not using the power of definition like:

"Containers can be accessed like python dictionaries, but internal they 
are high order datastructures for optimized for performance.
If you iterate over a container be careful not to change the content 
while the iteration.
This example show how not to iterate over a container:

           for key in self.context.keys() :
                del self.context[ key ]

To delete all elements from a container use the containers .clear() method.
"

Best Regards,

Volker



-- 
====================================================
   inqbus it-consulting      +49 ( 341 )  5643800
   Dr.  Volker Jaenisch      http://www.inqbus.de
   Herloßsohnstr.    12      0 4 1 5 5    Leipzig
   N  O  T -  F Ä L L E      +49 ( 170 )  3113748
====================================================



More information about the Grok-dev mailing list