title: how to check if variables is exist from arrays?
body: <p>I am working on my code to create the variables for the pixels.</p>
  
  <p>I'm using the variables <code>pixel_start = 375</code>, <code>pixel_middle = 724</code> and <code>pixel_end = 1073</code> as I want to check each of them in each at a time.</p>
  
  <p>When I try this:</p>
  
  <pre><code>def GoRight(self):
      basex, basey = self.getControl(347 + self.channels_Index).getPosition()
      basew = self.getControl(347 + self.channels_Index).getWidth()
  
      # change program controls to display the proper junks
      if self.channels_Index != len(self.program_buttons) - 1:
          CurrentRow = self.program_buttons[self.programs_Index].control.getX()
          CurrentWidth = self.program_buttons[self.programs_Index].control.getWidth()
          CurrentX = self.program_buttons[self.programs_Index].control.getX()
          print CurrentWidth
          #print CurrentX
          pixel_start = 375
          pixel_middle = 724
          pixel_end = 1073
          self.move_flag = True
  
  
          #Check on pixels size between start and end time
          if CurrentRow != pixel_end:
              if pixel_start == 375:
                  if int(prog_width) == 2437:
                      programs_width = 2082
                      self.getControl(int(prog_id)).setWidth(int(programs_width))
  
  
                  elif int(prog_width) == 2082:
                      programs_width = 1735
                      self.getControl(int(prog_id)).setWidth(int(programs_width))
  
  
                  elif int(prog_width) == 1735:
                      programs_width = 1392
                      self.getControl(int(prog_id)).setWidth(int(programs_width))
  
  
                  elif int(prog_width) == 1392:
                      programs_width = 1038
                      self.getControl(int(prog_id)).setWidth(int(programs_width))
  
  
                  elif int(prog_width) == 1038:
                       programs_width = 691
                       self.getControl(int(prog_id)).setWidth(int(programs_width))
  
  
                       if int(prog_width) == 691:
                           self.programs_Index += 1
                      self.setFocus(self.program_buttons[self.programs_Index].control)
  
  
                   elif int(prog_width) == 691:
                        programs_width = 342
                        self.getControl(int(prog_id)).setWidth(int(programs_width))
  
  
                   elif int(prog_width) == 342:
                        self.getControl(int(prog_id)).setVisible(False)
                        self.getControl(int(prog_id)).setPosition(int(pos_X) - 350, int(pos_Y))
  
  
                   elif int(pos_X) == 724:
                       nextprogram = int(prog_id) + 1
                       self.getControl(int(nextprogram)).setPosition(1073, int(pos_Y))
                       self.getControl(int(nextprogram)).setVisible(True)
  
  
                       elif int(pos_X) == 1073:
                           self.move_flag = True
                           print "catch this one"
  
  
  
              if pixel_middle == 724:
                  program_button = [elem.control for elem in self.program_buttons]
                  programs_id = list()
                  program_width = list()
                  positions_X = list()
                  positions_Y = list()
  
                  for elem in program_button:
                      programs_id.append(elem.getId())
                      positions_X.append(elem.getX())
                      positions_Y.append(elem.getY())
                      program_width.append(elem.getWidth())
                   programs_id = map(str, programs_id)
                   posX = map(str, positions_X)
                   posY = map(str, positions_Y)
                   program_width = map(str, program_width)
  
                   for pos_X, pos_Y, prog_id, prog_width in zip(positions_X, positions_Y, programs_id, program_width):
                       if int(pos_X) == 724:
                           self.getControl(int(prog_id)).setPosition(375, int(pos_Y))
  
  
                       if self.move_flag == True:
                           print "catch this two"
                           if pixel_end == 1073:
                               program_button = [elem.control for elem in self.program_buttons]
                           programs_id = list()
                           program_width = list()
                           positions_X = list()
                           positions_Y = list()
  
                           for elem in program_button:
                               programs_id.append(elem.getId())
                               positions_X.append(elem.getX())
                               positions_Y.append(elem.getY())
                               program_width.append(elem.getWidth())
                           programs_id = map(str, programs_id)
                           posX = map(str, positions_X)
                           posY = map(str, positions_Y)
                           program_width = map(str, program_width)
  
                           for pos_X, pos_Y, prog_id, prog_width in zip(positions_X, positions_Y, programs_id, program_width):
                               if int(pos_X) == 1073:
                                   print "catch this three"
                                   self.getControl(int(prog_id)).setPosition(724, int(pos_Y))
  
  
                      self.channels_row += 1
                      #print self.channels_row
                      if self.channels_row &lt;= 7:
                           pass
                           #self.move_flag = False
               self.move_flag = False
  </code></pre>
  
  <p>It will loops on the code as it will firing twice.</p>
  
  <p>in <code>pixel_middle</code>, you can see that I'm using this:</p>
  
  <pre><code>for pos_X, pos_Y, prog_id, prog_width in zip(positions_X, positions_Y, programs_id, program_width):
      if int(pos_X) == 724:
          self.getControl(int(prog_id)).setPosition(375, int(pos_Y))
  </code></pre>
  
  <p>in <code>pixel_end</code> bottom line:</p>
  
  <pre><code>if self.move_flag == True:
      print "catch this two"
      if pixel_end == 1073:
          ...
          for pos_X, pos_Y, prog_id, prog_width in zip(positions_X, positions_Y, programs_id, program_width):
              if int(pos_X) == 1073:
                  self.getControl(int(prog_id)).setPosition(724, int(pos_Y))
  </code></pre>
  
  <p>I'm trying to check if the pixels in the arrays for the <code>pos_X</code> does exist and if they do not exist then move to the next variable, e.g move from <code>pixel_middle</code> and use <code>pixel_end</code> instead. I tried to block the code from firing twice when I try to use <code>if self.move_flag == True</code>, but it did not help.</p>
  
  <p>I'm using the arrays for the <code>pos_X</code> to check that if the pixels value <code>375</code>, <code>724</code> does exist in the arrays. </p>
  
  <p>Can you please show me an example of how I can use to check that if the pixels in the arrays do exist and if they don't exist using with <code>pixel_middle</code> and <code>pixel_end</code> ?</p>