Re: conditional running of code portion

2012-08-06 Thread Serhiy Storchaka
On 06.08.12 20:02, Dieter Maurer wrote: Serhiy Storchaka writes: On 05.08.12 09:30, Steven D'Aprano wrote: If you are working in a tight loop, you can do this: if VERBOSE_FLAG: for item in loop: print(DEBUG_INFORMATION) do_actual_work(item) else: for item in lo

Re: conditional running of code portion

2012-08-06 Thread Dieter Maurer
Serhiy Storchaka writes: > On 05.08.12 09:30, Steven D'Aprano wrote: >> If you are working in a tight loop, you can do this: >> >> if VERBOSE_FLAG: >> for item in loop: >> print(DEBUG_INFORMATION) >> do_actual_work(item) >> else: >> for item in loop: >> do_act

Re: conditional running of code portion

2012-08-06 Thread Ramchandra Apte
I just googled the OP's question and found a StackOverflow question. That question's solution mentions pypreprocessor. On 6 August 2012 08:20, Steven W. Orr wrote: > On 8/5/2012 12:43 AM, Ramchandra Apte wrote: > >> Try pypreprocessor >>

Re: conditional running of code portion

2012-08-05 Thread Steven W. Orr
On 8/5/2012 12:43 AM, Ramchandra Apte wrote: Try pypreprocessor . Better idea: You should be using the logging module if you want to print debug information quickly.It uses threads and is optimized to run fas

Re: conditional running of code portion

2012-08-05 Thread Serhiy Storchaka
On 05.08.12 09:30, Steven D'Aprano wrote: If you are working in a tight loop, you can do this: if VERBOSE_FLAG: for item in loop: print(DEBUG_INFORMATION) do_actual_work(item) else: for item in loop: do_actual_work(item) Or this: if VERBOSE_FLAG: def d

Re: conditional running of code portion

2012-08-04 Thread Steven D'Aprano
On Sat, 04 Aug 2012 21:16:04 -0700, JW Huang wrote: > Hi, > > How can I implement something like C++'s conditional compile. > > if VERBOSE_MODE: print debug information else: do nothing > > But I don't want this condition to be checked during runtime as it will > slow down the code. You've pr

Re: conditional running of code portion

2012-08-04 Thread Ramchandra Apte
Try pypreprocessor . Better idea: You should be using the loggingmodule if you want to print debug information quickly.It uses threads and is optimized to run fast. On 5 August 2012 09:46, JW Huang wrote: > H