equivalent of source command in tcl for python

M

mark.collier

Many times I am developing a code in a file and I want to, for
example, exit at a specific line so that I can test something. In tcl
you can just put an exit command in and source the file. Is there an
equivalent for python? Thanks,
 
R

Ralf Schoenian

Many times I am developing a code in a file and I want to, for
example, exit at a specific line so that I can test something. In tcl
you can just put an exit command in and source the file. Is there an
equivalent for python? Thanks,

Hi Mark,

there is:

import sys
sys.exit()

Ralf Schoenian
 
P

Paddy3118

Hi Mark,

there is:

import sys
sys.exit()

Ralf Schoenian

....Which is what I would use instead of typing 0/0 at a convenient
point, if I could fight my laziness :)
 
A

alex23

import sys
sys.exit()

And if you run your code using the -i switch, a la:

python -i mycode.py

Python will open the interpreter in interactive mode after it hits
sys.exit() (or any uncaught exception), with the full state of the
program up to that point available. Which can be very handy during
testing for ensuring that your expectations of that state are correct.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top