pylint woes

Chris Angelico rosuav at gmail.com
Sun May 8 18:10:44 EDT 2016


On Mon, May 9, 2016 at 6:49 AM, Dan Sommers <dan at tombstonezero.net> wrote:
> On Sun, 08 May 2016 23:01:55 +1000, Chris Angelico wrote:
>
>> ... I like to recommend a little thing called "IIDPIO debugging" - If
>> In Doubt, Print It Out.  That means: If you have no idea what a piece
>> of code is doing, slap in a print() call somewhere. It'll tell you
>> that (a) the code is actually being executed, and (b) whatever info
>> you put between the parens (ideally, some key variable or
>> parameter). Part A is often the important bit :) ...
>
> Having spent a long time developing embedded systems, I wholeheartedly
> agree.  In spirit.  Isn't that what the logging module is for?  Fine
> grained control, as centralized or distributed as is warranted, over
> program output?
>
>> ... The trouble with a verbose flag controlling all print() calls is
>> that IIDPIO debugging suddenly doesn't work; plus, it's easy to copy
>> and paste code to some other module and not notice that you don't have
>> a verbosity check at the top, and then wonder why disabling verbose
>> doesn't fully work. Both problems are solved by having a dedicated
>> spam function, which will simply error out if you didn't set it up
>> properly.
>
> Hey!  That sounds just like the logging module....  ;-)

Absolutely. I say "print" in IIDPIO because it's a word that people
understand across languages, across frameworks, etc, etc, but when you
start doing more of it, the logging module is definitely superior - if
you need just one reason to use it, it would be to *leave those prints
in place* so the next person doesn't need to reach for IIDPIO at all.

(Also, I teach print() because it's one less module to explain. But
experienced programmers should get some familiarity with it.)

ChrisA



More information about the Python-list mailing list