def boolean(value):
 if isinstance(value, bool):
  return value
 if (not value):
  raise ValueError('boolean type must be non-null')
 value = value.lower()
 if (value in ('true', '1')):
  return True
 if (value in ('false', '0')):
  return False
 raise ValueError('Invalid literal for boolean(): {0}'.format(value))

def boolean ( value ) : if isinstance ( value , bool ) : return value if ( not value ) : raise ValueError ( 'boolean type must be non-null' ) value = value . lower ( ) if ( value in ( 'true' , '1' ) ) : return True if ( value in ( 'false' , '0' ) ) : return False raise ValueError ( 'Invalid literal for boolean(): {0}' . format ( value ) )
test whether a string is a tk boolean .