python: Improve support for edit callbacks.