I have this list comprehension which returns elements in the list lst_fcflds
if they are not in the list RROPFields
:
nfld_rrop = [i for i in lst_fcflds if i not in RROPFields]
and want a filter so that if OBJECTID
or SHAPE
are in lst_fclfds, they will also NOT be returned - like:
nfld_rrop = [i for i in lst_fcflds if i not in RROPFields and not in ["OBJECTID","SHAPE"]]
You're just missing one i
nfld_rrop = [i for i in lst_fcflds if i not in RROPFields and i not in ["OBJECTID","SHAPE"]]
^
However for performance, I would add one step first to create a set
so you can do faster membership lookups.
filters = set(RROPFields + ["OBJECTID", "SHAPE"])
nfld_rrop = [i for i in lst_fcflds if i not in filters]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With