mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Monkey patch __nonzero__ onto QPyNullVariant for easier null check.
Who doesn't love monkeys :)
This commit is contained in:
parent
3115c30948
commit
8392c93d8e
@ -22,3 +22,15 @@ __date__ = 'January 2007'
|
||||
__copyright__ = '(C) 2007, Martin Dobias'
|
||||
# This will get replaced with a git SHA1 when you do a git archive
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
from PyQt4.QtCore import QPyNullVariant
|
||||
from types import MethodType
|
||||
|
||||
# Add a __nonzero__ method onto QPyNullVariant so we can check for null values easier.
|
||||
# >>> value = QPyNullVariant("int")
|
||||
# >>> if value:
|
||||
# >>> print "Not a null value"
|
||||
def __nonzero__(self):
|
||||
return False
|
||||
|
||||
QPyNullVariant.__nonzero__ = MethodType(__nonzero__, None, QPyNullVariant)
|
||||
|
Loading…
x
Reference in New Issue
Block a user