I have the canonical shebang at the top of my python scripts.
#!/usr/bin/env python
However, I still often want to export unbuffered output to a log file when I run my scripts, so I end up calling:
$ python -u myscript.py &> myscript.out &
Can I embed the -u option in the shebang like so...
#!/usr/bin/env python -u
and only call:
$ ./myscript.py &> myscript.out &
...to still get the unbuffering? I suspect that won't work, and want to check before trying. Is there something that would accomplish this?
alias ppython="python -u"
and just use#!/usr/bin/env ppython
– Torxedenv
searches for an executable on the path, and aliases are not on the path. Aliases don't work on the shebang line in the same way and for the same reason that built-ins don't work on the shebang line. If your OS allows this, please share! – Chris Johnson