Python Forum
how to combine mumtiple for loops in single loop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to combine mumtiple for loops in single loop
#27
this may be crude way, but solving by purpose, is there any other way?
 session = Session(hostname=host, community='xxxwifi', version=2)
     system_items = session.bulkwalk('1.3.6.1.4.1.25053.1.3.2.1.1.2.2.1.1')
     mac = []
     for item in system_items:
        mac.append(':'.join('{:02x}'.format(ord(x)) for x in item.value))
     session = Session(hostname=host, community='ttlwifi', version=2)
     SSGMAC,WLCip,SCGAPName,SCGAPNumSta,SCGAPConnStatus = (list(session.bulkwalk('1.3.6.1.4.1.25053.1.3.2.1.1.2.2.1.' + c ,non_repeaters=0, max_repetitions=50)) for c in ('1','10','5','15','16'))
     for i in range(len(WLCip)):
         print ('{} {} {} {} {} {}'.format(host,WLCip[i].value,mac[0],SCGAPName[i].value,SCGAPNumSta[i].value,SCGAPConnStatus[i].value))
Output:
10.124.115.10 10.138.69.54 04:4f:aa:34:a2:80 RuckusAP 6 Connect 10.124.115.10 10.138.69.75 04:4f:aa:34:a2:80 RuckusAP 8 Connect 10.124.115.10 10.138.69.40 04:4f:aa:34:a2:80 RuckusAP 4 Connect 10.124.115.10 10.138.64.173 04:4f:aa:34:a2:80 RuckusAP 12 Connect 10.124.115.10 10.138.64.172 04:4f:aa:34:a2:80 RuckusAP 5 Connect 10.124.115.10 10.138.69.8 04:4f:aa:34:a2:80 RuckusAP 5 Connect 10.124.115.10 10.138.69.55 04:4f:aa:34:a2:80 RuckusAP 2 Connect 10.124.115.10 10.138.69.74 04:4f:aa:34:a2:80 RuckusAP 18 Connect 10.124.115.10 10.138.69.102 04:4f:aa:34:a2:80 RuckusAP 9 Connect

print ('{} {} {} {} {} {}'.format(host,WLCip[i].value,mac[i],SCGAPName[i].value,SCGAPNumSta[i].value,SCGAPConnStatus[i].value))
some changes
Reply


Messages In This Thread
RE: how to combine mumtiple for loops in single loop - by anna - Mar-08-2018, 10:10 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Nested for loops - help with iterating a variable outside of the main loop dm222 4 1,697 Aug-17-2022, 10:17 PM
Last Post: deanhystad
  Print output in single file using pramika loop deepakkhw 1 2,128 Jul-11-2020, 11:57 AM
Last Post: j.crater
  Unable to combine print statements in for loop adeana 2 2,054 Jun-12-2020, 05:08 PM
Last Post: adeana
  Is it possible to avoid 2 loops inside another loop? SvetlanaofVodianova 2 2,224 Nov-27-2019, 02:30 PM
Last Post: Gribouillis
  Loop through folder of Excel Files and extract single column fioranosnake 2 4,587 Oct-28-2019, 05:19 PM
Last Post: fioranosnake
  Combine two scripts and loop BMC 2 2,104 Feb-17-2019, 02:13 PM
Last Post: BMC
  Loops - new terminal output to file for each loop jm_ice 1 2,626 Dec-21-2018, 02:42 PM
Last Post: ichabod801
  Python-for loop print into single line dragan979 4 7,136 Nov-23-2018, 01:01 AM
Last Post: wavic
  Using nested for loop with a single list mikeavison 3 3,348 Aug-12-2017, 08:13 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020