Based on the code of Robin2:
Robin2: Try the attached file - just rename it to .py
I have created a library for both Python and Arduino to allow bi-directional communication between these two platforms: PyDuino Bridge. You can find the GitHub repository here. There, I give instructions about how to install it and an example of use.