This isn't possible using the BSD socket API (which is roughly the API Python exposes in its socket
module) - except by creating 2 ** 16 - 1 sockets and using them to bind to all ports.
It's possible using lower-level interfaces such as the TUN/TAP system offered by Linux.