简体   繁体   中英

How can I supply command line arguments to a script in Enthought Canopy Editor?

I am using the new Enthought Canopy code editor on OSX (64-bit). To test a script, I need to provide a command-line argument like:

import sys
config_file = sys.argv[1]

However, I can't seem to find a way to provide a command line argument to the script. I tried using a macro as:

def run():
    code_task = get_active_task()
    code_task.run_current_file('config_filename')

...but I get an error that run_current_file only takes one argument (presumably self ).

Passing command line argument is not supported currently, but something that we plan to add.

As a work around, you could run the script normally, first, when it would fail, and then get the previous command from IPython history, and manually add in the args required.

Alternatively, you can set sys.argv to the args that you want to pass to your script, before running it. This seems sort of hackish to me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM