pylint woes

Larry Hudson orgnut at yahoo.com
Sun May 8 21:28:46 EDT 2016


On 05/08/2016 03:07 PM, Chris Angelico wrote:
> On Mon, May 9, 2016 at 6:45 AM, Larry Hudson via Python-list
> <python-list at python.org> wrote:
>> On 05/08/2016 06:01 AM, Chris Angelico wrote:
>> [snip...]
>>>
>>> ...                                          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)...
>>
>>
>> My personal variation of IIPPID debugging is to use input() instead of
>> print().  For example:
>>
>>      input('x = {}, y = {} --> '.format(x, y))
>>
>> Then the program stops at this point so you can examine the values.  <Enter>
>> will continue the program or ^C will abort (if you see what the problem is
>> now).  Of course this can't be used in all situations, but it's handy where
>> it can.
>>
>> Note that my personal preference is to stick that "-->" as a prompt at the
>> end, but obviously this (or a similar marker) is optional.
>
> Neat technique. Not something to use *every* time (and not always
> sensible - eg you don't normally want to stall out a GUI thread), but
> definitely worth keeping in the arsenal.
>
> ChrisA
>

Agreed.  As I said in my post, it is certainly not a universally valid approach, but I do find 
it useful in many cases.

      -=- Larry -=-




More information about the Python-list mailing list