replace print and exception with Py3.0 grammar style