Isn't this line redundant with the getattr? I think it would be equivalent to just remove it.

P.S. Thanks for this!