Answer the question
In order to leave comments, you need to log in
How to call a function with arguments from the console?
How to call a function with arguments from the console?
Let's say we have a function like this:
def hello_somebody(somebody):
print("hello %s" % somebody)
def hello_somebody(somebody):
print("hello %s" % somebody)
hello_somebody(input())
python file.py hello_somebody("Igor")
Answer the question
In order to leave comments, you need to log in
You can also look towards a ready-made library, for example python-fire
An example from the documentation:
import fire
class Calculator(object):
"""A simple calculator class."""
def double(self, number):
return 2 * number
if __name__ == '__main__':
fire.Fire(Calculator)
python calculator.py double 10 # 20
python calculator.py double --number=15 # 30
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question