Python Create Function Dynamically Typed