How can I execute the below simple script called foo.py from the (bash) command line?
def hello():
return 'Hi :)'
I tried the following and got an error.
$ python -c 'import foo; print foo.hello()'
File "<string>", line 1
import foo; print foo.hello()
^
SyntaxError: invalid syntax
I’m able to execute the following but just receive no output.
$ python foo.py
$
>Solution :
print foo.hello()
Is this Python2?
remove that print before function call:
$ python -c 'import foo; foo.hello()'
Or make it like python3 syntax:
$ python -c 'import foo; print(foo.hello())'