01-22-2026 07:29 AM
I noticed that when you do a
device.learn("all") or device.learn("config"), the config dictionary seems to be built strangely. It seems if a value has over 80 characters, its string is carried over to the next key. My guess is it has something to do with terminal width, but it's a little annoying. Has anyone noticed this, or is there a way around it?
{
"some setting": "...some long value ov"
"er 80 characters": {}
}
01-22-2026 08:08 AM
never tried all - may be when i get access to Lab will try.
But I used the code below get information it works. what is the use case of get all information.
device.learn("interface")
device.learn("routing")
Alternatively you can try below :
device.execute("terminal length 0")
cfg = device.execute("show running-config")
=====️ Preenayamo Vasudevam ️=====
***** Rate All Helpful Responses *****
01-22-2026 09:00 AM
what is the use case of get all information.
One reason to learn all would be to create a mock device.
But I used the code below get information it works.
device.learn("interface")
device.learn("routing")
Yes, device.learn("all") and device.learn("config") both work and get the information, it's just weird how the data is parsed.
I did notice if you do the following, it seems to parse fine.
device.execute("terminal length 0")
device.execute("terminal width 200")
config = device.learn("config") # or config = device.learn("all").config
print(config)
Alternatively you can try below :
device.execute("terminal length 0")
cfg = device.execute("show running-config")
Thanks. I was just trying to use .learn() instead of executing the command myself because of what the docs mention:
Why use learn instead of a parser? The parsed output for different devices can result in different data structures. The learn function, by contrast, results in a consistent set of keys, which means that you can write one script that works on different devices.
01-22-2026 10:12 AM
ok, on what device are you trying? Nexus or IOS XE?
Let me test when I get a chance on my Lab,
=====️ Preenayamo Vasudevam ️=====
***** Rate All Helpful Responses *****
01-22-2026 10:18 AM
NXOS
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide