title: Concatenation in Python in Wrong order and Overwrites part of String
body: <p>I am getting a weird output from a Python script</p>
  
  <p>When running the code in a loop for the actual execution involving Paramiko it seems to reverse order of the variable to print, while overwriting the beguinning of the output..</p>
  
  <p>All source text to process is the same for both. One is grabbed via Paramiko over ssh from router, another I manually grabbed and pasted it as a local variable.</p>
  
  <p><strong>Current output:</strong></p>
  
  <pre><code>with testis 10.8.11.72 from 10.8.11.72 (10.111.72.1)
  </code></pre>
  
  <p><strong>Desired Ouput and Output with Static local variable:</strong></p>
  
  <pre><code>Best Path is 10.8.11.73 from 10.8.11.73 (10.111.73.1) with localpref 120
  </code></pre>
  
  <p>I have no earthly Idea why this is going on. Please see below for more info and execution. <strong>Help?</strong></p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>import paramiko
  
  router_channel.send('sh ip bgp 10.23.24.32\n')
  buff = ''
  best_test =()
  while not buff.endswith('#'):
      resp = router_channel.recv(99999)
      buff += resp
  #DMVPN variable Declaration.
  bgp_show = buff
  bgp_list =  bgp_show.split('Local')
  bgp_list.pop(0)
  for x in bgp_list:
      if 'best' in x:
          best_list = x.split('\n')
          for x in best_list:
              best_list = [x.strip(' ') for x in best_list]
              local_pref = best_list[2]
              local_pref = local_pref.split(',')
              local_pref = local_pref[2]
              best_test = best_list[1]
          print '********'
          print buff
          print '********'
          print "Best Path is " + best_test + " with " + "test"
          print '********'
  </code></pre>
  
  <p><strong>Execution of the code:</strong>    </p>
  
  <pre><code>dirp@localhost Test Python Scripts]$ python splice.py
      ********
      sh ip bgp 10.23.24.32
      BGP routing table entry for 10.23.24.32/28, version 367886
      Paths: (6 available, best #5, table default)
        Advertised to update-groups:
       1          2          3          4          5          6          7         
       9         
    Refresh Epoch 1
    Local, (Received from a RR-client)
      10.8.111.73 from 10.8.111.73 (10.111.73.2)
        Origin IGP, metric 0, localpref 105, valid, internal
        rx pathid: 0, tx pathid: 0
    Refresh Epoch 2
    Local, (Received from a RR-client)
      10.8.11.72 from 10.8.11.72 (10.111.72.1)
        Origin IGP, metric 0, localpref 120, valid, internal, best
        rx pathid: 0, tx pathid: 0x0
    Refresh Epoch 3
    Local, (Received from a RR-client)
      10.8.11.73 from 10.8.11.73 (10.111.73.1)
        Origin IGP, metric 0, localpref 110, valid, internal
        rx pathid: 0, tx pathid: 0
  router#
  ********
   With testis 10.8.11.72 from 10.8.11.72 (10.111.72.1)
  ********
  </code></pre>
  
  <p><strong>Static Code:</strong></p>
  
  <pre><code>bgp_list =  bgp.split('Local')
  bgp_list.pop(0)
  
  #pprint.pprint( bgp_list )
  
  #print bgp_list[2]
  
  for x in bgp_list:
      if 'best' in x:
          best_list = x.split('\n')
          for x in best_list:
              best_list = [x.strip(' ') for x in best_list]
              local_pref = best_list[2]
              local_pref = local_pref.split(',')
              local_pref = local_pref[2]
          print '********'
          print bgp
          print '********'
          print "Best Path is " + best_list[1] + ' with' + local_pref
          print '********'    
  </code></pre>
  
  <p><strong>Ouput when not putting it in a loop but assigning the variable locally:</strong></p>
  
  <pre><code>derp@localhost Test Python Scripts]$ python splitty1.py 
  ********
  sh ip bgp 10.23.24.32 | exclude local
  BGP routing table entry for 10.23.24.32/28, version 122378
    Advertised to update-groups:
       1          2          3          4          5          6          7         
       9         
    Refresh Epoch 1
    Local, (Received from a RR-client)
      10.8.111.72 from 10.8.111.72 (10.111.72.2)
        Origin IGP, metric 0, localpref 105, valid, internal
        rx pathid: 0, tx pathid: 0
    Refresh Epoch 1
    Local, (Received from a RR-client)
      10.8.11.72 from 10.8.11.72 (10.111.72.1)
        Origin IGP, metric 0, localpref 110, valid, internal
        rx pathid: 0, tx pathid: 0
    Refresh Epoch 2
    Local, (Received from a RR-client)
      10.8.11.73 from 10.8.11.73 (10.111.73.1)
        Origin IGP, metric 0, localpref 120, valid, internal, best
        rx pathid: 0, tx pathid: 0x0
    Refresh Epoch 2
    Local
      10.8.11.73 from 10.9.0.1 (10.15.1.41)
        Origin IGP, metric 0, localpref 120, valid, internal
        Originator: 10.111.73.1, Cluster list: 10.15.1.41
        rx pathid: 0, tx pathid: 0
    Refresh Epoch 2
    Local
      10.8.11.73 from 10.8.0.1 (10.15.1.41)
        Origin IGP, metric 0, localpref 120, valid, internal
        Originator: 10.111.73.1, Cluster list: 10.15.1.41
        rx pathid: 0, tx pathid: 0
    Refresh Epoch 2
    Local, (Received from a RR-client)
      10.8.111.73 from 10.8.111.73 (10.111.73.2)
        Origin IGP, metric 0, localpref 115, valid, internal
        rx pathid: 0, tx pathid: 0
  ********
  Best Path is 10.8.11.73 from 10.8.11.73 (10.111.73.1) with localpref 120
  ********
  [derp@localhost Test Python Scripts]$ 
  </code></pre>