This feature request seems uncontroversial, so I'll add it
in version 3.2 unless anyone can think of a compelling
reason not to.
I would probably implement it like this, though:
---------------------------
def __nonzero__(self):
return bool(self._fields)
---------------------------
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I was about to implement this, but the Python documentation
entry for __nonzero__ says:
"""
Called to implement truth value testing, and the built-in
operation bool(); should return False or True, or their
integer equivalents 0 or 1.
When this method is not defined, __len__() is called, if it
is defined (see below). If a class defines neither __len__()
nor __nonzero__(), all its instances are considered true.
"""
kinterbasdb._RowMapping already defines __len__, so there's
no need to define __nonzero__ also.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Logged In: YES
user_id=414645
This feature request seems uncontroversial, so I'll add it
in version 3.2 unless anyone can think of a compelling
reason not to.
I would probably implement it like this, though:
---------------------------
def __nonzero__(self):
return bool(self._fields)
---------------------------
Logged In: YES
user_id=414645
I was about to implement this, but the Python documentation
entry for __nonzero__ says:
"""
Called to implement truth value testing, and the built-in
operation bool(); should return False or True, or their
integer equivalents 0 or 1.
When this method is not defined, __len__() is called, if it
is defined (see below). If a class defines neither __len__()
nor __nonzero__(), all its instances are considered true.
"""
kinterbasdb._RowMapping already defines __len__, so there's
no need to define __nonzero__ also.