Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Equivalent of BREAK command
#1
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
Reply
#2
You can use sys.exit() for that, or raise SystemExit. However, that is usually done with the control flow of your program.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  equivalent commands saeed_balk 2 2,679 Sep-23-2018, 05:44 AM
Last Post: saeed_balk

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020