05-31-2019 02:43 AM
Hi! I’m trying to access in python to the elements of a yang list. The yang model is:
list Prenotazione {
key "TempoAtt";
unique "TempoDis";
leaf TempoAtt {
type string
}
…
And the code I’m trying to use is something
FirstElementKey = service.Prenotazione.????
In order to access the leaf inside le list element with code such as:
MyData = service.Prenotazione[FirstElementKey].LeafName
How can I do? Is it corect to assume the lis is ordered according to the key?
Solved! Go to Solution.
05-31-2019 06:02 AM
Hi, in service create code, the service object is an instance of the particular service being instantiated at that moment.
For example (using your yang model):
service.TempoAtt
If you want to access data from other service instances use the root object like so:
root.services.Prenotazione[FirstElementKey]
BTW root.services.Prenotazione returns an iterator so you can just walk it without needing to know the keys.
For what I have seen yes, the service is ordered by the key.
05-31-2019 06:02 AM
Hi, in service create code, the service object is an instance of the particular service being instantiated at that moment.
For example (using your yang model):
service.TempoAtt
If you want to access data from other service instances use the root object like so:
root.services.Prenotazione[FirstElementKey]
BTW root.services.Prenotazione returns an iterator so you can just walk it without needing to know the keys.
For what I have seen yes, the service is ordered by the key.
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