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