Deprecation removal and other idiomatic updates

Remove or replacing old codes with more modern idioms
1. Deprecated `BaseException`
2. `while 1:`
3. updated to `print()` function