title: Local variable 'Veh_C2X_attributes' referenced before assignment Source?
body: <p>I tried to run this script from a microsimulation software PTV VISSIM. and getting this error. Local variable 'Veh_C2X_attributes' referenced before assignment  Source?? in my script i have created a list named 'Veh_C2X_attributes' using a list comprehension. Any help regarding this would be highly appreciated. Thanks</p>
  
  <p>Script.</p>
  
  <pre><code>def Init():
      #Global Parameters
      global distDistr
      global Vehicle_Type_C2X_no_message
      global Vehicle_Type_C2X_HasCurrentMessage
      Veh_attributes = None
  
      distDistr = 1 # number of Distance distribution used for sending out a C2X message
      Vehicle_Type_C2X_no_message = '101' # number of C2X vehicle type (no active message) has to be a string!
      Vehicle_Type_C2X_HasCurrentMessage = '102' # number of C2X vehicle type with active message has to be a string!
      return
  
  
  
  def Main():
      # Get several attributes of all vehicles:
      Veh_attributes = Vissim.Net.Vehicles.GetMultipleAttributes(('Pos', 'VehType', 'No'))
      if len(Veh_attributes) &gt; 0: # Check if there are any vehicles in the network:
         # Filter by VehType C2X:
          Veh_C2X_attributes = None
          Veh_C2X_attributes = [item for item in Veh_attributes if item[1] == Vehicle_Type_C2X_no_message or item[1] == Vehicle_Type_C2X_HasCurrentMessage]    #Getting Error here
  #Check if the Vehicle is in the range
      for C2X_Veh in range(len(Veh_C2X_attributes)):
          if Veh_C2X_attributes[C2X_Veh][0]==300:
              Veh_sending_Msg = Vissim.Net.Vehicles.ItemByKey(Veh_C2X_attributes[C2X_Veh][3])
              Coord_Veh = Veh_sending_Msg.AttValue('CoordFront') # reading the world coordinates (x y z) of the vehicle
              PositionXYZ = Coord_Veh.split(" ")
              Pos_Veh_SM = Veh_sending_Msg.AttValue('Pos') # relative position on the current link
              Veh_sending_Msg.SetAttValue('C2X_HasCurrentMessage', 1)
              Veh_sending_Msg.SetAttValue('C2X_SendingMessage', 1)
              Veh_sending_Msg.SetAttValue('C2X_MessageOrigin', Pos_Veh_SM)
              # Getting vehicles which receive the message:
              Veh_Rec_Message = Vissim.Net.Vehicles.GetByLocation(PositionXYZ[0], PositionXYZ[1], distDistr)
      return
  </code></pre>