The python example is missing the most important part, which is how to make your script work with external dependencies. Here is a working example.py with external dependencies:
#! /usr/bin/env nix-shell
#! nix-shell -i python3 -p python3 -p python3Packages.requests -p python3Packages.fire
import requests
import fire
class CLI:
def get(self, url):
return requests.get(url).status_code
fire.Fire(CLI)
Run with
chmod +x example.py
./example.py get https://example.com