In this example how to call "function func_call_from_terminal" from python terminal when the code running?
example: The name of the python script is "TEST.py"
def func_call_from_terminal():
# in this function I need to print I_Value ...
# where this function must call from terminal during...
# the running script TEST.py.
if __name__ == "__main__":
I_Value = 1
Flag = True
while Flag :
I_Value += 1
if I_Value == 1e9
Flag = False
1 Answer 1
Just open terminal and use this command
python -c 'import TEST; TEST.func_call_from_terminal()'
answered Feb 4, 2022 at 17:42
Peter Plevko
3131 silver badge11 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-py
KeyboardInterruptexception.sys.argvand call the function depending on the arguments.I?