0

This is my shell script, and I want to run the method foo(param):

#!/bin/sh 
python /Users/username/Desktop/forTrump/test.py

How would I run a function inside test.py using the shell script above?

Martin Tournoij
28k24 gold badges110 silver badges158 bronze badges
asked Mar 6, 2016 at 19:13
1

1 Answer 1

1
python -c 'import test; print test.foo(param)'
answered Mar 6, 2016 at 19:27
Sign up to request clarification or add additional context in comments.

3 Comments

If you are satisfied with the answer can you mark it as answered
Please start writing halfway-decent answers with explanations, not just code dumps, and stop hassling OPs to accept.
I would like to run this in a shell script with absolute path "/Users/username/Desktop/forTrump/test.py" I am not printing anything just running the method, which will run to a file, should I still include "print"?

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.