Re: Useful decorator

2007-04-14 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > if __debug__: >generate_bazillion_items = truncate(20)(generate_bazillion_items) > > Now you don't have to comment/uncomment dozens of lines all over your > application, but only set a single global. The cool thing about organizing the program as

Re: Useful decorator

2007-04-14 Thread Steven D'Aprano
On Sat, 14 Apr 2007 15:03:00 -0700, Paul Rubin wrote: > Then to chop bazillion_items to 20 items, I just write: > > @truncate(20) > def generate_bazillion_items(): >for line in bazillion_line_file: > yield itemify(line) > > When I want to run the whole file, I comment o

Re: Useful decorator

2007-04-14 Thread Paul McGuire
On Apr 14, 5:03 pm, Paul Rubin wrote: > In the course of writing a bunch of generator-oriented code I kept > wanting to temporarily truncate the output of generators for debugging, > i.e. I might have a function like > > def generate_bazillion_items(): >for li

Re: Useful decorator

2007-04-14 Thread James Stroud
Paul Rubin wrote: > In the course of writing a bunch of generator-oriented code I kept > wanting to temporarily truncate the output of generators for debugging, > i.e. I might have a function like > > def generate_bazillion_items(): >for line in bazillion_line_file: > yield i