(Oct-30-2017, 10:51 AM)wavic Wrote: If device.data is a list, data = [b for b in device.data] is meaningless. It's the same as data = device.data.
That is not true. List is mutable, thus is you just do
data = device.data
change in data would affect also device.data and vice versa.>>> my_list = [1, 2, 3] >>> a_list = [x for x in my_list] >>> b_list = my_list >>> my_list[0] = 100 >>> my_list [100, 2, 3] >>> a_list # still has the original values [1, 2, 3] >>> b_list [100, 2, 3] # has new value at index 0, same as my_list >>>an alternative to list comprehension for creating a copy would be list slicing
data = device.data[::]