pprinting generators

Ville Vainio vvainio at tp.spt.fi
Mon Jul 1 03:00:13 EDT 2002


"Steve Holden" <sholden at holdenweb.com> wrote in message news:<H0_S8.108273$mF.22455 at atlpnn01.usenetserver.com>...

> It wouldn't be very helpful of pprint to exhaust the generator so you
> couldn't access the values, would it? What if the generator were infinite?

The pattern I use pprint (in writing scrip/batch-oriented apps):

1. Write code to produce a huge data structure.
2. pprint the data structure, analyze, comment out pprint.
3. write code to act according to the data structure.

So I didn't realize some people actually *leave* those pprints in
place :). I understand consuming the data structure might be a
slightly unwanted side effect for just printing it for viewing.
Contraty to popular belief, I was not smoking crack at the time of
original posting.

-- Ville



More information about the Python-list mailing list