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: openSUSE 13.2 (home desktop, home laptop, work desktop), Ubuntu 14.04 LTS (server), OpenELEC 5.0 (HTPC), Debian GNU/Linux 7.7.0 (mini laptop), Android 4.2.1 (tablet)