def valid_qname(val):
 try:
  (prefix, localpart) = val.split(':')
  return (valid_ncname(prefix) and valid_ncname(localpart))
 except ValueError:
  return valid_ncname(val)

def valid_qname ( val ) : try : ( prefix , localpart ) = val . split ( ':' ) return ( valid_ncname ( prefix ) and valid_ncname ( localpart ) ) except ValueError : return valid_ncname ( val )
a qname is either ncname or ncname : ncname .