def is_valid_mpls_label(label):
 if ((not isinstance(label, numbers.Integral)) or (4 <= label <= 15) or ((label < 0) or (label > (2 ** 20)))):
  return False
 return True

def is_valid_mpls_label ( label ) : if ( ( not isinstance ( label , numbers . Integral ) ) or ( 4 <= label <= 15 ) or ( ( label < 0 ) or ( label > ( 2 ** 20 ) ) ) ) : return False return True
validates label according to mpls label rules rfc says: this 20-bit field .