F.Rahmouni
F.Rahmouni

Reputation: 56

How to Call a function from python terminal?

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

Upvotes: 1

Views: 704

Answers (1)

Peter Plevko
Peter Plevko

Reputation: 163

Just open terminal and use this command

python -c 'import TEST; TEST.func_call_from_terminal()' 

Upvotes: 3

Related Questions