cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
701
Views
15
Helpful
2
Replies

Check empty leaf set in python api

sfloresk
Cisco Employee
Cisco Employee

Is there a way to check if an empty list has been set using the python API?

1 Accepted Solution

Accepted Solutions

sfloresk
Cisco Employee
Cisco Employee

It can be done using the exists() method. Will return "True" if has been set, otherwise the result will be "False". (Credits to Viktor Leijon)

View solution in original post

2 Replies 2

sfloresk
Cisco Employee
Cisco Employee

It can be done using the exists() method. Will return "True" if has been set, otherwise the result will be "False". (Credits to Viktor Leijon)

The empty leaf can also be passed to the function bool(), so bool(root.my_empty_leaf) will return its truth.

Python will call the bool() function whenever it sees an object that supports it inside an if statement, so you can also just use the leaf directly in an if test
If root.my_empty_leaf :
Do something