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 ste...@syslang.net wrote: On 8/5/2012 12:43 AM, Ramchandra Apte wrote: Try pypreprocessor

Re: conditional running of code portion

2012-08-06 Thread Dieter Maurer
Serhiy Storchaka storch...@gmail.com 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:

Re: conditional running of code portion

2012-08-06 Thread Serhiy Storchaka
On 06.08.12 20:02, Dieter Maurer wrote: Serhiy Storchaka storch...@gmail.com 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:

Re: conditional running of code portion

2012-08-05 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 profiled

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

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 http://code.google.com/p/pypreprocessor/ . Better idea: You should be using the logging http://docs.python.org/library/logging.html module if you want to print debug information quickly.It uses threads and is optimized to run fast.

conditional running of code portion

2012-08-04 Thread JW Huang
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. Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list

Re: conditional running of code portion

2012-08-04 Thread Ramchandra Apte
Try pypreprocessor http://code.google.com/p/pypreprocessor/ . Better idea: You should be using the logginghttp://docs.python.org/library/logging.htmlmodule 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