Python: Add support for attributes in hooks