Mechanics functions in Python