In June 2023, the Web VPython Go Direct library was updated. One change to the library was to return a ‘None’ value from gdx.read() when a new sensor value is not yet available. The previous library did not return a ‘None’; instead, it sent duplicates of the sensor value until the sensor value updated.

The change made to the library in June 2023 is not backward compatible. This means that code created prior to this may break or act differently. Prior to the update, programs did not include code to deal with a ‘None’ value. The fix, therefore, is to modify your program to handle a ‘None’ value returned by gdx.read(). Typically, when a ‘None’ is returned, the best response is to go back to the beginning of the data collection loop and try again. For instance, the data collection loop will be similar to this:

while not gdx.vp_close_is_pressed():
     rate(50)
     if gdx.vp_collect_is_pressed():
          measurements = gdx.read() 
          if measurements is None: 
               continue
          ball.radius = measurements[0] 

The difference between this data collection loop and a data collection loop with the previous library is the code to deal with the ‘None’ value:

measurements = gdx.read() 
     if measurements is None: 
               continue

If you have found that your Web VPython programs that use Go Direct devices no longer work as expected, you may have to add the code to deal with the ‘None’ value, as shown above. For more information on the Go Direct library and the functions used to create a Web VPytyhon program with Go Direct sensors, visit our Getting Started Guide.