Re: How to write verbose scripts

2008-09-06 Thread Lie
On Sep 3, 6:31 pm, Uwe Schmitt <[EMAIL PROTECTED]> wrote: > On 2 Sep., 18:55, Steven D'Aprano <[EMAIL PROTECTED] > > > > cybersource.com.au> wrote: > > I find myself writing command line tools in Python where I wish to > > include "verbose" output to stdout. > > > I start with a helper function: >

Re: How to write verbose scripts

2008-09-04 Thread Ben Finney
Steven D'Aprano <[EMAIL PROTECTED]> writes: > On Tue, 02 Sep 2008 13:07:33 -0400, Joe Riopel wrote: > > > On Tue, Sep 2, 2008 at 12:55 PM, Steven D'Aprano > > <[EMAIL PROTECTED]> wrote: > >> Is there a better way of doing this than the way I am going about it? > > > > Would the logging module he

Re: How to write verbose scripts

2008-09-04 Thread Steven D'Aprano
On Tue, 02 Sep 2008 13:07:33 -0400, Joe Riopel wrote: > On Tue, Sep 2, 2008 at 12:55 PM, Steven D'Aprano > <[EMAIL PROTECTED]> wrote: >> Is there a better way of doing this than the way I am going about it? > > Would the logging module help, and just print the output to the stdout > (or a file) i

Re: How to write verbose scripts

2008-09-03 Thread BJörn Lindqvist
2008/9/3 Hendrik van Rooyen <[EMAIL PROTECTED]>: > > Steven D'Aprano wrote: > >>Is there a better way of doing this than the way I am going about it? > > Not sure if its "better", but I would keep the messages in a table or dict and > have different tables or dicts for different levels of verbosit

Re: How to write verbose scripts

2008-09-03 Thread Uwe Schmitt
On 2 Sep., 18:55, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > I find myself writing command line tools in Python where I wish to > include "verbose" output to stdout. > > I start with a helper function: > > def print_(obj, level=0): >     if _verbosity >= level: >         print

Re: How to write verbose scripts

2008-09-03 Thread Bruno Desthuilliers
John Machin a écrit : On Sep 3, 3:52 am, Mensanator <[EMAIL PROTECTED]> wrote: On Sep 2, 11:55 am, Steven D'Aprano <[EMAIL PROTECTED] if (p & 1)==1: print_evens = True else: print_evens = False if (p & 2)==2: print_odds = True else: print_odds = False if (p & 4)==4:

Re: How to write verbose scripts

2008-09-03 Thread Hendrik van Rooyen
Steven D'Aprano wrote: >Is there a better way of doing this than the way I am going about it? Not sure if its "better", but I would keep the messages in a table or dict and have different tables or dicts for different levels of verbosity, and write a displayer that knows about the verbosity - T

Re: How to write verbose scripts

2008-09-02 Thread Mensanator
On Sep 2, 4:14 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Sep 3, 3:52 am, Mensanator <[EMAIL PROTECTED]> wrote: > > > On Sep 2, 11:55 am, Steven D'Aprano <[EMAIL PROTECTED] > > > if (p & 1)==1: > > print_evens = True > > else: > > print_evens = False > > if (p & 2)==2: > > pr

Re: How to write verbose scripts

2008-09-02 Thread John Machin
On Sep 3, 3:52 am, Mensanator <[EMAIL PROTECTED]> wrote: > On Sep 2, 11:55 am, Steven D'Aprano <[EMAIL PROTECTED] > > if (p & 1)==1: > print_evens = True > else: > print_evens = False > if (p & 2)==2: > print_odds = True > else: > print_odds = False > if (p & 4)==4: >

Re: How to write verbose scripts

2008-09-02 Thread MRAB
On Sep 2, 5:55 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > I find myself writing command line tools in Python where I wish to > include "verbose" output to stdout. > > I start with a helper function: > > def print_(obj, level=0): >     if _verbosity >= level: >         print

Re: How to write verbose scripts

2008-09-02 Thread Diez B. Roggisch
Steven D'Aprano schrieb: I find myself writing command line tools in Python where I wish to include "verbose" output to stdout. I start with a helper function: def print_(obj, level=0): if _verbosity >= level: print obj And then I end up with functions or methods looking like th

Re: How to write verbose scripts

2008-09-02 Thread Mensanator
On Sep 2, 11:55 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > I find myself writing command line tools in Python where I wish to > include "verbose" output to stdout. > > I start with a helper function: > > def print_(obj, level=0): > if _verbosity >= level: > prin

Re: How to write verbose scripts

2008-09-02 Thread Joe Riopel
On Tue, Sep 2, 2008 at 12:55 PM, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > Is there a better way of doing this than the way I am going about it? Would the logging module help, and just print the output to the stdout (or a file) instead? -- http://mail.python.org/mailman/listinfo/python-list