cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1568
Views
5
Helpful
2
Replies

Get the value of the enumeration type in python

Hello team,

How could I get the enum-value in my python part.

for exemple I have the Yang portion in my package :

leaf my-enum{
        type enumeration {
            enum single{value 1;}
            enum dual{value 2;}            
        }
    }

And in my python part I'd to get the value 1 or 2 instead of single or dual.

 

regards.

2 Replies 2

hniska
Cisco Employee
Cisco Employee

In [14]: my_enum
Out[14]: Enum string="interface " value="1"

In [15]: my_enum.value
Out[15]: 1

In [16]: my_enum.string
Out[16]: 'interface\xa0'

Hello I have tried this in my template file and it work fine. thx for your support.

<enum_val>{number(enum-value(/my_enum))}</enum_val>