With the -c
(command) argument (assuming your file is named foo.py
):
$ python -c 'import foo; print foo.hello()'
Alternatively, if you don't care about namespace pollution:
$ python -c 'from foo import *; print hello()'
And the middle ground:
$ python -c 'from foo import hello; print hello()'
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…