I´m trying to get access to a variable from a python script to the command lines.
I run following command line with several args:
!python test.py --model I3D_resnet50 --dataset kinetics400
In this test.py there is variable Test1.
If I use sys.exit(Test1) in test.py there will be just the value printed in the command line, but I need the value saved in a variable.
Is this possible?
importthat module (test) from your code and call the function that (hopefully) return that value instead of running it on the command line. It depends on howtest.pyis written.print, rather thansys.exit(which will make your script appear to have failed).!pythonsuggests you are running your command from a Jupyter notebook; I am not sure how to capture the output in that environment. (From the shell, you would writex=$(python test.py python test.py --model I3D_resnet50 --dataset kinetics400).x=!(python test.py --model I3D_resnet50 --dataset kinetics400)variable=x[-1]print(variable)