Say I have some python script that looks something like
# myscript.py
#!bin/env python
def func(argv):
<some debugging print messages>
<some logic>
return some_string
def main():
return func(sys.argv)
How can I capture the returned string value of this script in a bash script or terminal session (to print to console or use as value in another command)?
Have seen several other similar posts on SO (return value from python script to shell script, store return value of a Python script in a bash script), but these don't appear to account for the fact of needing the intermediate messages to remain in the code (eg. something like
#echo "$(myscript.py 'input')"
ends up including all of the python script's debug messages along with the return value). Does anyone know what could be done here?