How to call a function with arguments from the console?

Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
How to call a function with arguments from the console?
We have, for example, the function:
def hello_somebody(somebody): print("hello %s" % somebody)

As this function is called from the windows cmd?
Know that you can do this:
def hello_somebody(somebody): print("hello %s" % somebody) hello_somebody(input())

and call file.
I want a function like this one:python hello_somebody("Igor")
If you can implement it or the easier option above?
by | 4 views

2 Answers

0 like 0 dislike
You can also look in the direction of ready-made libraries, 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)

Call from the command line:
python double 10 # 20 python double --number=15 # 30
0 like 0 dislike
In the simplest cases, use sys.argv, in more complex and such
110,608 questions
257,186 answers
28,082 users