Output set to 'low' when new variable in buffer
Your problem is in one tricky option for arduino's com connection. When you reopen COM port where arduino is connected your arduino resets automatically.

Here's workaround from arduino.cc: 


  DisablingAutoResetOnSerialConnection
  
  The simple way that doesn't require
  any permanent modifying of your hardware or software configuration
  changes:
  
  Stick a 120 ohm resistor in the headers between 5v and reset (you can
  find these on the isp connector too). 120 is hard to find so just
  combine resistors. Don't go below 110 ohms or above 124 ohms, and
  don't do this with an isp programmer attached. You can just pull out
  the resistor when you want auto-reset back.


http://playground.arduino.cc/Main/DisablingAutoResetOnSerialConnection

Or you can just modify you script to be able to start over without reopening it.
For example use a loop there and some exit command to end that loop:

try:
    while True:
        do_something()
except KeyboardInterrupt:
    pass


https://stackoverflow.com/questions/13180941/how-to-kill-a-while-loop-with-a-keystroke
Replace do_something() with this part of your code:

ser.reset_input_buffer()
ser.reset_output_buffer()
pin_number= int(sys.argv[1])
high_or_low=int(sys.argv[2])

ser.write(struct.pack('&gt;5B',8,1,pin_number,high_or_low,9))


I hope I was clear enough.