stop script without exiting interpreter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • homerobse
    New Member
    • Jun 2014
    • 2

    stop script without exiting interpreter

    This is a continuation to an old post (http://bytes.com/topic/python/answer...ng-interpreter) that I think a found a better answer.

    The question was:
    "I'm fairly new to Python and I've lately been running a script at
    the interpreter while working on it. Sometimes I only want to
    run the first quarter or half etc. What is the "good" way to do this?

    Possible ugly hacks include:

    - stick an undefined name at the desired stop point
    - comment out the last half

    I do not like these and assume that I have overlooked the obvious.

    Thanks,
    Alan Isaac"
  • homerobse
    New Member
    • Jun 2014
    • 2

    #2
    the answer using ipython

    Code:
    from IPython import embed
    
    def f():
        b=2
        embed() # this stops execution and goes to the interpreter
    
    print 'oi'
    a=1
    f()

    Comment

    Working...