for key in Dict: blah
instead of
for key in Dict.keys():
which constructs a list that I don't want or need.
Using the internal structure of dictionaries python
could take care of the details for me. I think this
is what the original poster had in mind.
My personal favorite way to do this is to use a
walker class associated with each container class,
which knows the internal representation of each container
and how to move from one element to the next -- in the
case of dictionaries the "walking" could be done without
creating *any* new objects. (I actually use walkers now using
while loops a lot.) Walkers can also be used outside of
loops for more general purposes.
Suitably generalized this could also allow the user to
define iterations over any container class:
for Node in Graph: blah
for Leaf in Btree: blah
for tuple in SQLquery: blah
Of course this wouldn't be a good idea if it slows down
the main interpretation loop much.
Aaron Watters
Department of Computer and Information Sciences
New Jersey Institute of Technology
University Heights
Newark, NJ 07102
phone (201)596-2666
fax (201)596-5777
home phone (908)545-3367
email: aaron@vienna.njit.edu