Menu

#7 rowmapping 2

closed
nobody
None
5
2005-07-06
2004-11-12
Anonymous
No

you need this too

def __nonzero__(self):
if self._fields:
return True
return False

Discussion

  • David S. Rushby

    David S. Rushby - 2004-11-16

    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)
    ---------------------------

     
  • David S. Rushby

    David S. Rushby - 2005-07-06
    • status: open --> closed
     
  • David S. Rushby

    David S. Rushby - 2005-07-06

    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.

     

Log in to post a comment.

Auth0 Logo