Nov-29-2019, 04:42 AM
hello
what is the use of
what is the use of
if __name__ == "__main__": main(sys.argv[1:])can i pass my file name in this?
use of sys.argv
|
Nov-29-2019, 04:42 AM
hello
what is the use of if __name__ == "__main__": main(sys.argv[1:])can i pass my file name in this?
Nov-29-2019, 04:59 AM
when you execute a script from the command like, argv will contain all of the arguments.
example: $ python myscript.py -a -dc -q then argv will contain: argv[0]: myscript.py argv[1]: -a argv[2]: -dc argv[3]: -q
Nov-29-2019, 05:02 AM
(This post was last modified: Nov-29-2019, 05:09 AM by deepakkr3110.)
ok. my issue is i don't want to pass argument every time so i define all the arguments in my file called configuration-file.ini and i want it to read from this file, so you tell me how can i do so?
example: $ python myscript.py configuration-file.ini here is the whole code: https://github.com/JamesBarwell/haproxy-...-status.py output: https://github.com/JamesBarwell/haproxy-status.py i don't wan to pass multiple argument every time when i run the program. so i put all the sock path in a different file and i want to call it from there
Nov-29-2019, 05:41 AM
Your other thread is all about that - how to use config file, but you don't follow directions. I will lock this thread now. Keep discussion in https://python-forum.io/Thread-hatop-issue
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link Create MCV example Debug small programs |
|
Possibly Related Threads… | |||||
Thread | Author | Replies | Views | Last Post | |
How do I call sys.argv list inside a function, from the CLI? | billykid999 | 3 | 829 |
May-02-2023, 08:40 AM Last Post: Gribouillis |
|
sys.argv method | nngokturk | 3 | 1,143 |
Jan-23-2023, 10:41 PM Last Post: deanhystad |
|
import argv | Scott | 3 | 5,951 |
Apr-01-2021, 11:03 AM Last Post: radix018 |
|
Not all data returned from sys.argv | ecdhyne | 2 | 2,822 |
Sep-05-2019, 08:27 PM Last Post: buran |
|
Pyinstaller with Sys.Argv[] - “Failed to Execute Script”? | ironfelix717 | 0 | 5,353 |
Aug-07-2019, 02:29 PM Last Post: ironfelix717 |
|
I see is that sys.argv contains character strings | helenharry | 2 | 2,787 |
Jan-09-2019, 11:34 AM Last Post: DeaD_EyE |
|
How argv works? | Philia | 7 | 4,877 |
Dec-26-2018, 12:20 AM Last Post: metulburr |
|
sys.argv correct sintax? | enricosx | 3 | 3,248 |
Jul-25-2018, 09:27 AM Last Post: buran |
|
I gotta problem with making argv parameters | Bozx | 3 | 4,106 |
Apr-04-2017, 03:44 AM Last Post: alicarlos13 |
|
argv IndexError | hsunteik | 2 | 4,581 |
Dec-19-2016, 06:19 AM Last Post: hsunteik |