I probably didn't ask correctly: I would like a list value that can match any list: the "inverse" of (None,)
but even with (None,)
it will match item as None (which I don't want)
The point is I have a function working with: [x for x in my_list if x[field] not in filter_list]
and I would like to filter everything or nothing without making tests like:
if filter_list==(None,): return []
and if filter_list==('*',): return my_list
PS: I wanted to simplify my question leading to some errors (list
identifier) or stupid thing [x for x in x]
;)
Hi,
I need to do some filtering with list comprehension in python.
if I do something like that:
[x for x in list if x in (None,)]
I get rid of all values, which is fine
but I would like to have the same thing to match everything
I can do something like:
[x for x in list if x not in (None,)]
but it won't be homogeneous with the rest
I tried some things but for example (True,)
matches only 1
Note than the values to filter are numeric, but if you have something generic (like (None,)
to match nothing), it would be great
Thanks Louis