This is a very strange way of 'faking' a read-only file and after testing Python, it handles real read-only files fine
-rw-r--r-- 1 root root 0 Jun 10 17:28 test
python hello.py > test
bash: test: Permission denied
echo $?
1