I just ran into an interesting problem:
In Qapp, when I script a GDT Variable to check if a another GDT Table or Table Variable is empty, it does not work using pythonic way. How can I get to check if a Table Attribute (list) is empty or not without coming up with other creative solutions? Basically, the Attribute (list) or Table appears to never be empty despite containing no data.
BID Table has _device, id and mac_limit attributes.
GDT Table has attribute “note” that I use for scripting.
When I check if BID Table (list) or BID.bid attribute (list) is empty is doesn’t return true for empty using pythonic way:
#Check if BID.bid (list) is empty:
if not $BID.bid:
$cell = “PASSED: Bridge-Domains are not configured”.
Although empty, it doesn’t match and continues to go through next else statement: The value returned is “None”.
In the note, I run the following script:
if $mpls_ldp is None:
$cell = "NOT APPLICABLE: Device is not a PE Device."
if not $BID.bid:
$cell = "PASSED: Bridge-Domains are not configured."
code = 0
result = 
rc = $BID.GetRowCount()
for x in range(rc):
if $BID.mac_limit[x] is None:
code = code + 1
result.append("FAILED: " + str($BID.bid[x]) + " does not have a MAC address limit configured.")
if code == 0:
$cell = "PASSED: All Bridge-Domains have a MAC address limit configured."
$cell = '\n'.join(result)
$cell = "NOT REVIEWED: Unable to validate configuration."
Qapp with BID Table having content:
BID Table without content:
GDT Table, note variable showing “NONE” from $BID.bid attribute (list) output, despite being empty:
Best answer by dawal1337View original
I think I have found a workaround to my problem. It seems to work using the following method:
test = [None]
if $BID.bid == test:
» returns True, if list is empty.
» returns False, if not empty.