How to organize test cases with PyUnit

Alex Martelli aleax at aleax.it
Mon Jul 8 02:18:36 EDT 2002


Roy Smith wrote:
        ...
> parser.parse() is supposed to (and does) return a dictionary of
> dictionaries.  The line "for table in tables:" should read "for table in
> tables.keys():".  As written, it should raise a TypeError.  In the
> process of trying to figure out why it wasn't, I added the "print

In Python 2.2, you can loop directly on a dictionary, skipping the
costly step of extracting its list of keys with a .keys() call -- so,
if you're using Python 2.2, no TypeError would be raised here.

This is just a part of the benefit you get from Python 2.2's new
arrangement for iterators -- ability to iterate directly on such
objects as dictionaries and files.  Handy, speedy AND readable...!


Alex




More information about the Python-list mailing list