I found the answer to another question on how to call a specific def function from a python file on the command line, however a function called doesn't take any arguments:
$ python -c 'from foo import hello; print hello()'
(I deleted the print statement, as it seemed redundant for my needs, and I just call the function in this case)
Several answers talk about using argument parsing, but this will require changes to several files that already exist and are undesirable.
The final answer to this question is how to do what I want in bash (I need to know how to do this in powershell)
$ ip='"hi"' ; fun_name='call_from_terminal'
$ python -c "import ${fun_name} as cft; cft.test_term_fun(${ip})"
hi
Here is my python code
def operator (string):
print( "Operator here, I got your message: ", string)
and from powershell I want to call it something like:
$ python -c 'from myfile import operator; operator("my message here")'
Edit:
, powershell
python -c 'from testscript import operator; operator("test")'
,
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'test' is not defined