calc with constants

Some minor work needed to port to python3, but nothing significant