10-09-2023 07:04 PM
The existing yang module has a container named "global", from python when I tried to access the leaf (e.g. delay) using root.xxx.global.delay, the package failed to load because "global" is a keyword in python. Is there another way to access this container in python?
The yang module looks like this:
...
container global {
...
leaf delay {
type uint32;
description "xxx";
}
...
}
Solved! Go to Solution.
10-10-2023 01:18 AM
Just for completeness, other solutions are
root.xxx['global'].delay
or you can use the module prefix. So if global is defined in a yang module with a prefix 'm' you can access 'delay' using
root.xxx.m__global.delay
Note: there is a double underscore
Using the module prefix is mainly to disambiguate when you have two modules both of which use the same identifier, but comes in handy for python keywords as well.
10-09-2023 07:23 PM
Never mind, I think I can use get_elem in Transaction.
10-10-2023 01:18 AM
Just for completeness, other solutions are
root.xxx['global'].delay
or you can use the module prefix. So if global is defined in a yang module with a prefix 'm' you can access 'delay' using
root.xxx.m__global.delay
Note: there is a double underscore
Using the module prefix is mainly to disambiguate when you have two modules both of which use the same identifier, but comes in handy for python keywords as well.
10-11-2023 11:02 AM
Good to know that, thanks!
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