![]() |
Equivalent of BREAK command - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Equivalent of BREAK command (/thread-12948.html) |
Equivalent of BREAK command - vasaq - Sep-20-2018 Hello folks I am new to this forum. I hope I am not breaking any posting rules here. I have been looking at the equivalent of the matlab- BREAK command in python. My use case is such: I want to run code line by line and I want to use the break command to terminate the program and not consider anything after the break command. Please advice . Vas RE: Equivalent of BREAK command - ichabod801 - Sep-20-2018 You can use sys.exit() for that, or raise SystemExit . However, that is usually done with the control flow of your program.
RE: Equivalent of BREAK command - vasaq - Sep-20-2018 Thanks Ichabod for the immediate reply...do I have to import any library for this to work? I trued it and i get this error: File "C:/Users/Kabali/.spyder-py3/temp.py", line 7, in <module> sys.exit() NameError: name 'sys' is not defined Also ...my intention is such....lets say there is an existing piece of code and i want to "intervene" in the process at a halfway point and play around with the the math part of it or examine values...i want the break command to not run antything AFTER it....even if there is an syntax error or something after the BREAK statement. |