def setDebug( self, flag=True ):
if flag:<EOL><INDENT>self.setDebugActions( _defaultStartDebugAction, _defaultSuccessDebugAction, _defaultExceptionDebugAction )<EOL><DEDENT>else:<EOL><INDENT>self.debug = False<EOL><DEDENT>return self<EOL>
Enable display of debugging messages while doing pattern matching.
Set ``flag`` to True to enable, False to disable.

Example::

    wd = Word(alphas).setName("alphaword")
    integer = Word(nums).setName("numword")
    term = wd | integer

    # turn on debugging for wd
    wd.setDebug()

    OneOrMore(term).parseString("abc 123 xyz 890")

prints::

    Match alphaword at loc 0(1,1)
    Matched alphaword -> ['abc']
    Match alphaword at loc 3(1,4)
    Exception raised:Expected alphaword (at char 4), (line:1, col:5)
    Match alphaword at loc 7(1,8)
    Matched alphaword -> ['xyz']
    Match alphaword at loc 11(1,12)
    Exception raised:Expected alphaword (at char 12), (line:1, col:13)
    Match alphaword at loc 15(1,16)
    Exception raised:Expected alphaword (at char 15), (line:1, col:16)

The output shown is that produced by the default debug actions - custom debug actions can be
specified using :class:`setDebugActions`. Prior to attempting
to match the ``wd`` expression, the debugging message ``"Match <exprname> at loc <n>(<line>,<col>)"``
is shown. Then if the parse succeeds, a ``"Matched"`` message is shown, or an ``"Exception raised"``
message is shown. Also note the use of :class:`setName` to assign a human-readable name to the expression,
which makes debugging and exception messages easier to understand - for instance, the default
name created for the :class:`Word` expression without calling ``setName`` is ``"W:(ABCD...)"``.