Python Forum
ciscolib cdp output list printing support
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ciscolib cdp output list printing support
#4
use string
(Jul-25-2018, 11:18 AM)anna Wrote: is this ok?
well, that is a question only you can answer. Does it look like YOU want it?
for print you may use something like this, more pythonic
neighbours = [{'ip': '172.21.162.164', 'hostname': 'PUN-DIG-DIG-01-ONN-BR-BS-GL-01', 'remote_port': 'FastEthernet0/24', 'local_port': 'FastEthernet0/18'}, {'ip': '172.21.162.157', 'hostname': 'PUN-DIG-DIG-02-ONN-BR-BS-01', 'remote_port': 'FastEthernet0/24', 'local_port': 'FastEthernet0/15'}, {'ip': '172.21.162.71', 'hostname': 'PUN-DIG-DIG-01-ONN-BR-BS-70', 'remote_port': 'FastEthernet0/24', 'local_port': 'FastEthernet0/19'}, {'ip': '172.21.160.2', 'hostname': 'pu-dig-dig-r1-as01', 'remote_port': 'GigabitEthernet1/0/9', 'local_port': 'GigabitEthernet0/1'}]
my_ip = "172.21.160.3"
for item in neighbours:
    print('{my_ip}\t{ip}\t{hostname: <30}\t{remote_port}\t{local_port}'.format(my_ip=my_ip, **item))
or use some of the avalable packages for print tabular data:
https://stackoverflow.com/a/26937531/4046632
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
ciscolib cdp output list printing support - by anna - Jul-25-2018, 10:55 AM
RE: ciscolib cdp output list printing support - by buran - Jul-25-2018, 12:18 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Eight Queens Problem, error in printing list snl_9527 10 1,603 Apr-30-2025, 04:22 PM
Last Post: Gribouillis
  sum() list from SQLAlchemy output Personne 5 7,238 May-17-2022, 12:25 AM
Last Post: Personne
Question Printing through list.. again jesse68 2 1,906 Apr-16-2022, 03:24 PM
Last Post: jesse68
  help for list printing jip31 8 5,425 May-01-2021, 03:52 AM
Last Post: Pedroski55
  Problem printing last element from a list tester_V 3 4,260 Oct-30-2020, 04:54 AM
Last Post: tester_V
  Printing empty list? hhydration 2 2,932 Oct-28-2020, 11:34 AM
Last Post: Atekka
  How to append to list a function output? rama27 5 9,431 Aug-24-2020, 10:53 AM
Last Post: DeaD_EyE
  Printing images from a list Heyjoe 4 4,236 Jun-22-2020, 02:28 AM
Last Post: Heyjoe
  json.dumps list output qurr 12 7,654 Apr-08-2020, 10:13 PM
Last Post: micseydel
  If item in list = true, Output = xx kroh 0 1,921 Feb-19-2020, 09:17 AM
Last Post: kroh

Forum Jump:

User Panel Messages

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