pdb: How to use the 'break' parameter?

Peter J. Holzer hjp-python at hjp.at
Thu Aug 22 02:08:46 EDT 2024


On 2024-08-22 01:44:35 +0000, Kevin M. Wilson via Python-list wrote:
> break (Old_MacDonald:23 | name[indx] == 'd', indx = 4), based on the doc spec in python.org (https://docs.python.org/3/library/pdb.html#debugger-commands)
> Cell In[1], line 20
>     break (Old_MacDonald:23 | name[indx] == 'd', indx = 4)
>           ^
>           SyntaxError: invalid syntax
> I got one blank white screen when I entered the exact first line of the python.org-->b(reak) [([filename:]lineno | function) [, condition]]

You misunderstood the notation. The | means "or", it is not something
you have to type literally.

So the syntax is:
    either a line number (maybe in a different file) or a function name
    optionally followed by a condition after a comma

So in your case probably something like:

    break Old_MacDonald:23, name[indx] == 'd'

(I'm not sure what "indx = 4" was supposed to do. You can't assign
inside of a condition.)

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp at hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://mail.python.org/pipermail/python-list/attachments/20240822/c832bf36/attachment.sig>


More information about the Python-list mailing list