Skip to content


QPyNullVariant() equals to QPyNullVariant(), qgis.core.NULL
Browse files Browse the repository at this point in the history
>>>> from qgis.core import NULL
>>>> lyr.getFeatures().next().attributes()[0] == NULL
  • Loading branch information
m-kuhn committed Aug 29, 2013
1 parent f7b05ff commit dcd17fd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions python/
Expand Up @@ -46,7 +46,17 @@ def __nonzero__(self):
def __repr__(self):
return 'NULL'

def __eq__(self, other):
return isinstance(other, QPyNullVariant) or other is None

QPyNullVariant.__nonzero__ = MethodType(__nonzero__, None, QPyNullVariant)
QPyNullVariant.__repr__ = MethodType(__repr__, None, QPyNullVariant)
QPyNullVariant.__eq__= MethodType(__eq__, None, QPyNullVariant)

# define a dummy QPyNullVariant instance NULL in qgis.core
# this is mainly used to compare against
# so one can write if feat['attr'] == NULL:
from qgis import core
core.NULL = QPyNullVariant( int )
except ImportError:

0 comments on commit dcd17fd

Please sign in to comment.