update doctest code style and python3 compatible