Use pythonic boolean syntax in isvalidport()