While writing an application parsing command line arguments I would like to run it with various parameters.
I don't want to create a Run Configuration for every possible command line argument that I want my script to test with. Is there a way in PyCharm (and I guess with any JetBrains IDE) to make a Run Configuration that asks for the Script parameters when executed?
I am currently using PyCharm 3.1 (EAP).
目前唯一的可能是使用“启动前 | 显示此页面”选项。
Although yole's answer is the de facto way to be prompted for thw arguments before running a program, it is slightly annoying because:
Nothing you could do about that. (Except maybe file a ticket. Have you done that?)
I'm just adding what I used to do before Iknew aboutGoogled for this option for the sake of completeness (obvously, this is a hack in the least glamorous sense of the term). But it did suit my workflow as I often only had discrete lines to test with, and didn't switch that often.
sys.argv
(pass it through lambda args: [__name__] + args.split()
to reduce the boilerplate);I've found today that now is possible to ask for parameters using the "Prompt" macro on the "Run configuration" parameters field.
https://www.jetbrains.com/help/pycharm/code-running-assistance-tutorial.html#parameter-with-macros
I'm doing this on a Mac, but hopefully this will be helpful for Windows or Linux.
Go to Run > Edit Configurations There will be a dialog box that opens. Script: file you want to run (ending with .py) Script Parameters: the command line arguments Working Directory: directory where your project is.
My simple answer is adding another wrapper as the cover in the source code which will run on the selection you made through code branch or external command or file, so choosing different branch is just a 'ddp' tap distance in vim(line change for parameter settings). You dont have to depend on pycharm updating by building your own code world:)
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.