Incorporating (and extending) another contribution from Michael Grant for the Python interface