[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-list
Subject:    Re: WANT: bad code in python (for refactoring example)
From:       Chris Angelico <rosuav () gmail ! com>
Date:       2017-02-15 18:51:13
Message-ID: CAPTjJmoDQ_2MtNKQrL2zzzJnWu0EPEOs2VUUdk7CVqFk1pknYQ () mail ! gmail ! com
[Download RAW message or body]

On Thu, Feb 16, 2017 at 12:37 AM, Antoon Pardon
<antoon.pardon@rece.vub.ac.be> wrote:
>> But a better way, in my opinion, is to
>> use your editor to search for:
>>
>> print(
>>
>> and replace with:
>>
>> #print(
>
> You don't seem to understand, I don't want to disable all printing, only the
> diagnostics. That is easier to do if I use a different name for printing
> diagnostics than for regular I/O. Whether I disable it by defining an empty
> function or by commenting them out, doesn't really matter with this regard.
>
>> But even better, once you get to the point of putting print calls in more
>> than two or three places in your code, you should probably invest the time
>> to learn how to use the logging module.
>
> I know how to use the logging module. It is my experience that for a lot
> of rather small projects, the hassle of setting it up, is not worth it.
> YMMV.

Once you get to the point of saying either "but #print( might comment
out only the first line, so I can't wrap it" or "but #print( would
comment out too much, I only want to toggle some of the statements",
it's time to set up logging. Also, if you're building a daemon that
should play nicely with a larger system (eg a system process on
Unix/Linux), the logging module makes that work a lot easier, since
you can easily redirect it to a file or whatever you want.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic