title: Consolidating various SNMP transactions and assigning the OID and result of each to unique variables for further processing
body: <p>I am trying to write code that will have many SNMP transactions, some transactions could be bundled into the same <code>getCmd()</code> function of <code>PySNMP</code>. With that being said, I do not intend to print the value of the result of my SNMP transaction right away, sometimes further processing is needed. I.E: unpacking. Bundling two SNMP transactions looks like so:</p>
  
  <pre><code>from pysnmp.hlapi import *
  
  errorIndication, errorStatus, errorIndex, varBinds = next(
      getCmd(SnmpEngine(),
             CommunityData('somePasswd'),
             UdpTransportTarget(('somedev.example.com', 161)),
             ContextData(),
             #One MIB
             ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysName', '0')),
             #Second MIB
             ObjectType(ObjectIdentity('CISCO-CDP-MIB', 'cdpCacheAddress', 1,1)),
             lookupNames=True,
             lookupValues=True,
  ))
  
  if errorIndication:
      print(errorIndication)
  elif errorStatus:
      print('%s at %s' % (errorStatus.prettyPrint(),
                          errorIndex and varBinds[int(errorIndex) - 1][0] or '?'))
  else:
      for varBind in varBinds:
          print(' = '.join([x.prettyPrint() for x in varBind]))
  </code></pre>
  
  <p>The way that I see it if I want to assign the value of a specific MIB to a variable, I'd have to put an if..elseif statement under my last for loop to compare the value of the MIB that I am looking for to the current value of the oid iterables(i think is the term). So, my code would change like so:</p>
  
  <pre><code>for oid, value in varBinds:
      if oid == 'SNMPv2-MIB::sysName.0':
          #take specific actions
      elif oid == 'CISCO-CDP-MIB::cdpCacheAddress.1.1'
          #take different actions
  </code></pre>
  
  <p>I think this may be one way of doing things, however, I have a couple of questions:</p>
  
  <ol>
  <li><p>Is this an efficient way of handling multiple SNMP transactions? </p></li>
  <li><p>Is it better for code legibility to keep each SNMP Get transaction separate?</p></li>
  <li><p>When I do the following my OIDs are converted to human-friendly,
          MIBS:</p>
  
  <pre><code>    for varBind in varBinds
              print(' = '.join([x.prettyPrint() for x in varBind]))
  </code></pre></li>
  </ol>
  
  <p>But the following just gives me ugly oids: </p>
  
  <pre><code>     for oid, value in varBinds:
               print("oid:",oid,"Value",value):
  </code></pre>
  
  <p>by passing oid and value to my for loop, how do I end up with a
  human-friendly mib instead of the ugly oid?</p>
  
  <p>UPDATE:</p>
  
  <p>Passing <code>.loadMibs</code> to <code>ObjectIdentity</code>, like so: <code>ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysName', '0').loadMibs('SNMPv2-MIB'))</code> still gave me an OID when printing <code>oid</code> and <code>value</code> like this: <code>for oid, value in varBinds:</code></p>