That’s because what you have isn’t really a Python problem.
Originally Posted by gabbro
I guess you use IDLE since F5 seems to be the “Run module” key in it.
Activation and focussing of windows is the job of the window manager, not Python. I prefer “focus follows mouse” so I’m usually fine with active windows being in the background but I understand it may appear tricky to the uninitiated. Maybe you can fine tune these settings in Macs too? (Or maybe not.)
My armada: Debian GNU/Linux 8 (desktop, home laptop, work laptop), Raspbian GNU/Linux 8 (nameserver), Ubuntu 14.04.3 LTS (HTPC), PC-BSD 10.2 (testbed), Android 4.2.1 (tablet)