Gmail Notifier based on Arduino Uno

I had I project using arduino uno which is Gmail Notifier gmail notifier project (for dummies) – TINYenormous – Build it up to break it down again all things go well but when I disconnect and re-plug the arduino to the computer it stops working and never works till I reset it or re-upload the code or re-run the python script I think the problem is related to the serial port number which change after plugging the arduino

Every time I re-plug arduino the serial port changes so I had to change the number of serial port in the python script, so How can I fix the problem if it was the really problem ?

I am sorry if the question is repeated but I didn't find similar one in this forum by searching .

Hi this might be a long shot but if you're using windows or linux you should be able to retrieve information from either the system logs (linux, command: dmsg) or the device manager (windows, something to do with DEVCON in command line ) both would say an arduino UNO would be inserted (I'm using an Arduino UNO on windows at the mo and it's listed as Arduino UNO R3 (COM 5) where com 5 is the current port it's connected to)

You could have something in the python script along the lines of

On startup
search either dmesg (grep arduino) or windows devcon for currently connected arduno boards (you can import OS in python call any command line command and any results are returned as strings)
go through the result until you find the com port needed (or device path on linux e.g /dev/ttyACM0)
set that as the arduino's port in the python script

Hope this can be of help.