• import sys out of hello function.
  • arguments should be converted to int.
  • String literal that contain ' should be escaped or should be surrouned by ".
  • Did you invoke the program with python hello.py <some-number> <some-number> in command line?

import sys

def hello(a,b):
    print "hello and that's your sum:", a + b

if __name__ == "__main__":
    a = int(sys.argv[1])
    b = int(sys.argv[2])
    hello(a, b)
Answer from falsetru on Stack Overflow
🌐
Medium
medium.com › @evaGachirwa › running-python-script-with-arguments-in-the-command-line-93dfa5f10eff
Running Python script with Arguments in the command line | by Eva Mwangi | Medium
April 22, 2023 - The sys module provides functions and variables to manipulate Python’s runtime environment. Through sys.argv arguments are passed from the command line to the Python script.
Discussions

Passing argument to function from command line
My son wrote a command line program in ruby for me. I want to convert it to python. To run the program he has done this on the command line; “./myProgram.rb ‘argument’”. Then the 'argument ’ is passed into the program to be processed. I want to do the same in python. More on discuss.python.org
🌐 discuss.python.org
8
0
June 25, 2025
Modifying Python Script to Accept Command Line Arguments?
https://docs.python.org/3/library/argparse.html More on reddit.com
🌐 r/learnpython
5
2
March 3, 2024
How to run a python script with entering arguments
I need to now hoy to run a program call ‘osaki.py’ with 5 arguments (entering). I have read, but i could not be able to run it. Any one knows? More on forum.uipath.com
🌐 forum.uipath.com
0
0
March 31, 2023
Run Python script with arguments
Hi! I have a Python script I want to run in TouchDesigner. It takes a lot of optional arguments. In command line I would run it with something like: python script.py --arg1 strvalue --arg2 floatval --arg3 int --arg4 [.… More on forum.derivative.ca
🌐 forum.derivative.ca
0
0
July 6, 2017
🌐
Stanford CS
cs.stanford.edu › people › nick › py › python-main.html
Python main() - Command Line Arguments
Command line arguments like -affirm often select a mode or option for the run of the program, and these options typically begin with a dash as we have here. With the -hello option, the program prints a plain hello like this: ... With the -n option, the program prints the name a number of times, like this. $ python3 affirm.py -n 10 Maggie Maggie Maggie Maggie Maggie Maggie Maggie Maggie Maggie Maggie Maggie $ python3 affirm.py -n 100 Maggie Maggie Maggie Maggie Maggie Maggie Maggie Maggie Maggie Maggie Maggie Maggie Maggie Maggie Maggie Maggie Maggie Maggie Maggie Maggie Maggie Maggie Maggie Ma
🌐
Tutorials24x7
tutorials24x7.com › python › run-another-python-script-with-arguments-in-python-for-optimal-execution
Run Python scripts with arguments for optimal execution. Learn how.
April 29, 2024 - You can also run a Python script from another script using exec. The exec function in Python executes dynamically created Python code or scripts. caller_script.py: # First define arguments arg1 = "tutorial" arg2 = "for" arg3 = "developers" # Second, execute called script along with the arguments exec(open("called_script.py").read(), { 'arg1': arg1, 'arg2': arg2, 'arg3': arg3})
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-run-another-python-script-with-arguments-in-python
How to Run Another Python script with Arguments in Python - GeeksforGeeks
July 23, 2025 - Running a Python script from another ... This process involves using a subprocess or os module to execute the external script, and passing arguments can be achieved by appending them to the command line....
🌐
Python.org
discuss.python.org › python help
Passing argument to function from command line - Python Help - Discussions on Python.org
June 25, 2025 - My son wrote a command line program in ruby for me. I want to convert it to python. To run the program he has done this on the command line; “./myProgram.rb ‘argument’”. Then the 'argument ’ is passed into the progra…
🌐
Reddit
reddit.com › r/learnpython › modifying python script to accept command line arguments?
r/learnpython on Reddit: Modifying Python Script to Accept Command Line Arguments?
March 3, 2024 -

I am trying to modify an already existing code (https://github.com/ohyicong/decrypt-chrome-passwords/blob/main/decrypt_chrome_password.py) to take in command line arguments an example: python script.py "path_to_Local_State_file" "path_to_Login_Data_file" I think that this should be a pretty simple fix but chatGPT is not giving me the correct code when I test it how should I approach this.

Find elsewhere
🌐
Tutorialspoint
tutorialspoint.com › python › python_command_line_arguments.htm
Python - Command-Line Arguments
C:\Python311>python parser1.py C:\Python311>python parser1.py -h usage: parser1.py [-h] sample argument parser options: -h, --help show this help message and exit · The second command line usage gives −help option which produces a help message as shown. The −help parameter is available by default. Now let us define an argument which is mandatory for the script to run and if not given script should throw error.
🌐
Finxter
blog.finxter.com › how-to-execute-a-python-file-with-arguments-in-python
How to Execute a Python File with Arguments in Python? – Be on the Right Side of Change
This variable is defined on operating system level, so you can pass it within your calling Python script and fill it with the desired arguments. Fill the variable sys.argv with your desired values in the calling Python script. Load the Python file script.py into a Python string. Pass the Python ...
🌐
YouTube
youtube.com › fabio musanni - programming channel
Run Python Scripts With Command Line Arguments Using sys.argv (With Examples) - YouTube
💻 *Get the Source Code and support the channel* ❤️: https://www.buymeacoffee.com/fabiomusanni/e/187994⬇️ *LEARN ON THE BEST LEARNING PLATFORMS (LINKS BELOW)...
Published   March 29, 2023
Views   9K
🌐
UiPath Community
forum.uipath.com › help › studio
How to run a python script with entering arguments - Studio - UiPath Community Forum
March 31, 2023 - I need to now hoy to run a program call ‘osaki.py’ with 5 arguments (entering). I have read, but i could not be able to run it. Any one knows?
🌐
Analytics Vidhya
analyticsvidhya.com › home › 3 easy ways to handle command line arguments in python
3 Easy Ways to Handle Command Line Arguments in Python
January 15, 2025 - Command line arguments are a powerful tool for making your Python scripts more flexible and reusable. They allow you to pass args to python script different inputs to your script each time you run it, making it more versatile. We’ve explored three easy ways to handle command line arguments – using sys.argv, the getopt module, and the argparse module.
🌐
LabEx
labex.io › tutorials › python-how-to-execute-scripts-with-parameters-418940
How to execute scripts with parameters | LabEx
Learn essential Python script parameter techniques, explore command-line argument parsing, and master script execution with flexible input management strategies.
🌐
TouchDesigner
forum.derivative.ca › beginners
Run Python script with arguments - Beginners - TouchDesigner forum
July 6, 2017 - Hi! I have a Python script I want to run in TouchDesigner. It takes a lot of optional arguments. In command line I would run it with something like: python script.py --arg1 strvalue --arg2 floatval --arg3 int --arg4 [...] --last_arg Inside the script parser take care of them: [code]import argparse def parse_args(): parser.add_argument(‘–arg2’, nargs=‘+’, type=float, default=[1.0]') etc [a lot of def’s skipped] def main(): global args args = parse_args() render_single_image() if name ...
🌐
BetterTouchTool Community
community.folivora.ai › configuration help & general discussion
How to launch python script with arguments - Configuration Help & General Discussion - BetterTouchTool Community
May 24, 2020 - Hello, I've tried to launch a python script using the "Execute Shell Scrip/Task" or "Run Real JavaScript" but I don't know how to pass my variable (generated by user input) to my python script as an argument.
🌐
OpenSourceOptions
opensourceoptions.com › how-to-pass-arguments-to-a-python-script-from-the-command-line
How to Pass Arguments to a Python Script from the Command Line – OpenSourceOptions
The argv member of sys (sys.argv) will store all the information in the command line entry and can be accessed inside the Python script. Python’s getopt module can also be used to parse named arguments. Let’s go through some examples. To follow these examples, you’ll need to have Python installed on your system. If you don’t have Python installed, you can follow the tutorial in my FREE course to get you set up with an easy, reliable installation.
🌐
3D Slicer
discourse.slicer.org › support
Run a python script with command line arguments - Support - 3D Slicer Community
June 12, 2024 - Hi, I am trying to run a python script that accepts command line arguments as follows. ./Slicer --python-script /home/user/extract_centerlines_vmtk.py --data_dir /PATH/TO/DATA --end_points --network --network_curve --network_prop --centerline --centerline_curve --centerline_prop and the python script looks as follows def extract_centerlines(args): ... if __name__ == '__main__': parser = argparse.ArgumentParser(description="Extract centerlines from a dataset") parser.add_argument('--...
🌐
Reddit
reddit.com › r/learnpython › how to call a python file with arguments from another python file?
r/learnpython on Reddit: How to call a python file with arguments from another python file?
January 9, 2022 -

I have a file that collects data on a website given a URL. Using command line, I call call this file as:

python data_collector.py url

Now, I would like to capture this same functionality, but in another python script. I know I can import the file as a module and use the functions, but is it possible (or even useful) to simply call it in another file as if I were using command line and return the results? If so, is this an efficient manner of doing things?

🌐
GeeksforGeeks
geeksforgeeks.org › python › command-line-arguments-in-python
Command Line Arguments in Python - GeeksforGeeks
Comes with a built-in -h / --help flag. ... Since no arguments are defined, the script only supports the default -h/--help option. ... import argparse parser = argparse.ArgumentParser(description="Demo of argparse") parser.parse_args() ... ArgumentParser(description=...): creates a parser object. The description is shown when you use the help option. parse_args(): processes the arguments given when running the script.
Published   December 17, 2025