pass parameters to my python script saved on sololearn | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

pass parameters to my python script saved on sololearn

How can I pass parameters to my python script saved here on sololearn ?

12th May 2019, 3:59 PM
Alexander Poleshuk
Alexander Poleshuk - avatar
7 Answers
+ 8
You can use subprocess to do it https://code.sololearn.com/c7zzD6LGuE1k/?ref=app
12th May 2019, 6:19 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 6
subprocess.call("python source.py parameters")
12th May 2019, 6:32 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 2
You mean calling it with arguments from the console? I doubt you can do that here.
12th May 2019, 4:25 PM
HonFu
HonFu - avatar
+ 1
Try simply editing the argv variable maybe, that's the closest you'll get. argv = ["arg1"] print(argv[0]) # Prints arg1 Keep coding! - inxane
12th May 2019, 9:00 PM
inxanedev!
inxanedev! - avatar
0
By passing parameters, do you mean to functions? Do you have an example of what you want to do?
12th May 2019, 4:37 PM
Trigger
Trigger - avatar
0
I mean this: python myscript.py --param1=val1 --param2=val2, similar to console
12th May 2019, 4:57 PM
Alexander Poleshuk
Alexander Poleshuk - avatar
0
How can I pass argv parameters?
12th May 2019, 6:24 PM
Alexander Poleshuk
Alexander Poleshuk - avatar