ERROR REMOVED NULLS OF LIST... ? WHTSS 🤔

Very good days.
I have a problem that I can’t understand
It happens that I am obtaining all the views of my current project, as you can see it returns some “null” elements and I am trying to use an if to be able to keep those that are not null, I have tried to apply an example with “x”, “–” but it does not identify it as null, why is that???
On the other hand, when the “LIST.CLEAN” node is applied, it is possible to eliminate those nulls, but I am trying to solve it from PYTHON SCRIPT, in short, if it could be solved or am I forgetting something…
My goal is to solve it from PYTHON…
Thank you very much for your time…


ERROR NULLS.dyn (8.2 KB)

Line 43 try: if i is None: it’s a bit more forgiving in that it tests for ‘None’-ness rather than having to equal None
Alternately use the filter function OUT = list(filter(None, ElemVistas))

Edit I’ve had a look and the nulls are because Dynamo does not have an element wrapper for certain types of view - I cannot work out how to filter in python, so removing nulls after processing in python is the way to go

See also discussion here → Get all view templates with Python

If you are looking for view templates only, then the Crumple Package has a node for this.
image

Alternartively, there is also a well written list.Clean Node by Genius Loci, which the python might provide insight for you with this issue.

#Clean list or list of lists of all None or Empty lists in Python - Stack Overflow

def ClearList(primList):
result =
for sublist in primList:
if sublist is “”:
continue
elif sublist is None:
continue
if isinstance(sublist, list):
sublist = ClearList(sublist)
if not sublist:
continue
result.append(sublist)
return result

OUT = ClearList(IN[0])