Reports until 10:53, Wednesday 25 January 2017
H1 CDS
thomas.shaffer@LIGO.ORG - posted 10:53, Wednesday 25 January 2017 (33626)
Verbal bug fixed, rookie mistake

Verbal has been crashing at 00:00:03UTC some days and not others. I went through the code and found that it came from the Lock_Logging.py module that records lock data and puts it in a text file. From here I had to track down exactly where and what was going on, but I eventually found the issue and my stupid mistake. I wrote it a long time ago, so that maybe makes me feel a bit better....maybe not.

 


 

A good reminder to all the python users out there, because I have fallen into this trap more times than I would like to admit.



>>> a = [1,2,3,4]
>>> b = a
>>> b.append(5)
>>> print b
[1, 2, 3, 4, 5]
>>> print a
[1, 2, 3, 4, 5]

Unlike normal variable assignment, when assigning lists, Python will make both assignments point to the same list (  a -> [1,2,3,4] <- b ). So if you change list a, then list b will also change, and vis-versa.

The Solution: use list()



>>> a = [1,2,3,4]
>>> b = list(a)
>>> b.append(5)
>>> print b
[1, 2, 3, 4, 5]
>>> print a
[1, 2, 3, 4]
Hopefully my dumb mistakes can help prevent someone else making the same ones.