Is it possible to write a firewall in python? Say it would block all traffic?
I'm sure it's probably possible, but ill-advised.  As mcandre mentions, most OSes couple the low level networking capabilities you need for a firewall tightly into the kernel and thus this task is usually done in C/C++ and integrates tightly with the kernel.  The microkernel OSes (Mach et al) might be more amenable than linux. You may be able to mix some python and C, but I think the more interesting discussion here is going to be around "why should I"/"why shouldn't I" implement a firewall in python as opposed to just is it technically possible.
Is it possible to write a firewall in python?