Python assertions instead of raising exceptions manually