<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Accessing a a yang list in Python code in NSO Developer Hub Discussions</title>
    <link>https://community.cisco.com/t5/nso-developer-hub-discussions/accessing-a-a-yang-list-in-python-code/m-p/3865748#M3848</link>
    <description>&lt;P&gt;Hi, in service create code, the service object is an instance of the particular service being instantiated at that moment.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example (using your yang model):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;service.TempoAtt&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to access data from other service instances use the root object like so:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;root.services.Prenotazione[FirstElementKey]&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW root.services.Prenotazione returns an iterator so you can just walk it without needing to know the keys.&lt;/P&gt;
&lt;P&gt;For what I have seen yes, the service is ordered by the key.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 31 May 2019 13:02:23 GMT</pubDate>
    <dc:creator>jfloresr</dc:creator>
    <dc:date>2019-05-31T13:02:23Z</dc:date>
    <item>
      <title>Accessing a a yang list in Python code</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/accessing-a-a-yang-list-in-python-code/m-p/3865650#M3846</link>
      <description>&lt;P&gt;Hi! I’m trying to access in python to the elements of a yang list. The yang model is:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; list Prenotazione {&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; key "TempoAtt";&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; unique "TempoDis";&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; leaf TempoAtt {&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; type string&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; …&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;And the code I’m trying to use is something&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT face="courier new,courier"&gt;FirstElementKey = service.Prenotazione.????&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;In order to access the leaf inside le list element with code such as:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyData = service.Prenotazione[FirstElementKey].LeafName&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I do? Is it corect to assume the lis is ordered according to the key?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 09:43:59 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/accessing-a-a-yang-list-in-python-code/m-p/3865650#M3846</guid>
      <dc:creator>Fantolino</dc:creator>
      <dc:date>2019-05-31T09:43:59Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing a a yang list in Python code</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/accessing-a-a-yang-list-in-python-code/m-p/3865748#M3848</link>
      <description>&lt;P&gt;Hi, in service create code, the service object is an instance of the particular service being instantiated at that moment.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example (using your yang model):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;service.TempoAtt&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to access data from other service instances use the root object like so:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;root.services.Prenotazione[FirstElementKey]&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW root.services.Prenotazione returns an iterator so you can just walk it without needing to know the keys.&lt;/P&gt;
&lt;P&gt;For what I have seen yes, the service is ordered by the key.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 13:02:23 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/accessing-a-a-yang-list-in-python-code/m-p/3865748#M3848</guid>
      <dc:creator>jfloresr</dc:creator>
      <dc:date>2019-05-31T13:02:23Z</dc:date>
    </item>
  </channel>
</rss>

