It is tricky. Basically you have to get processing to close the serial port and your python script to open it. So ther needs some communication between the two.
Also when the port is opened or closed your arduino resets so you have to disable the auto reset circuit as well.