def bitcount(self, key, start=None, end=None):
        """Count set bits in a string.

        :raises TypeError: if only start or end specified.
        """
        if start is None and end is not None:
            raise TypeError("both start and stop must be specified")
        elif start is not None and end is None:
            raise TypeError("both start and stop must be specified")
        elif start is not None and end is not None:
            args = (start, end)
        else:
            args = ()
        return self.execute(b'BITCOUNT', key, *args)
def bitcount ( self , key , start = None , end = None ) : if start is None and end is not None : raise TypeError ( "both start and stop must be specified" ) elif start is not None and end is None : raise TypeError ( "both start and stop must be specified" ) elif start is not None and end is not None : args = ( start , end ) else : args = ( ) return self . execute ( b'BITCOUNT' , key , * args )
Count set bits in a string.

        :raises TypeError: if only start or end specified.