'Convert into bool'

@staticmethod
def _bool(b):

    if isinstance(b, bool):
        return b
    if isinstance(b, basestring):
        if (b.lower() in ('true', '1')):
            return True
        elif (b.lower() in ('false', '0')):
            return False
    if isinstance(b, (int, long)):
        if (b == 0):
            return False
        else:
            return True
    raise TypeError
