Command-line options to IPython *scripts*?

前端 未结 5 818
暖寄归人
暖寄归人 2020-12-23 13:58

I am often asked to debug Python scripts written by others. I would like to send these scripts to IPython so it will drop into an IPython shell at the point the script fail

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-23 14:43

    Simple example here.

    script.py

    from sys import argv
    
    script, first, second, third = argv
    
    print "The script is called:", script
    print "Your first variable is:", first
    print "Your second variable is:", second
    print "Your third variable is:", third
    

    shell:

    $ ipython script.py stuff things that
    The script is called: ex13.py
    Your first variable is: stuff
    Your second variable is: things
    Your third variable is: that
    

提交回复
热议问题