If you communicate over serial, you can have a look at Robin's updated Serial Input Basics tutorial. He also wrote a matching python side: Demo of PC-Arduino comms using Python - #11
And a more recent tutorial: Two ways communication between Python3 and Arduino - #27 by herbschwarz