How to pass parameters to a build in Sublime Text 3?

后端 未结 2 2029
心在旅途
心在旅途 2021-02-04 13:39

I\'m currently making a program (which requires some arguments) that runs on the terminal.

Now I would like to run this same program from Sublime Text, but I don\'t kno

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-04 14:19

    I find it easier to use a try catch with default arguments, Sublime's build system becomes annoying to manage. While you do fast paced dev you can just modify the arguments in the except statement.

    import sys
    try:
        if sys.argv[1]:
            Name = str(sys.argv[1])
    
    except:
        print "no argument given - using DERP"
        Name = "DERP"
    

提交回复
热议问题