Yesterday, for reasons best left unstated, I invented a technique for combining #bash and #Python into a single file.
The motivation was to have something a bit more powerful than the #! to decide which installed Python to use.
The magic is in line two:
#!/bin/bash
""""true"
# bash sees this, python ignores it
if [ -e /path/to/file ]; then
exec python3 "$0" "$@"
else
echo "OMG, something is missing"
exit 1
fi
"""
# begin python fun!
from thing import python_stuff
python_stuff()