PhilipTrauner / blog

Posts and comments found on my blog.
https://philip-trauner.me/blog
0 stars 0 forks source link

Python Tips: Dynamic function definition #7

Open utterances-bot opened 5 years ago

utterances-bot commented 5 years ago

Python Tips: Dynamic function definition - Philip Trauner

Function definition in Python can be considered static, right? Wrong!

https://philip-trauner.me/blog/post/python-tips-dynamic-function-definition

Ankita10 commented 5 years ago

Hi, I tried to follow your code to recreate the way you understood the dynamic functions. However I got a different response when i executed : signature(FunctionType) . I got an error, "no signature found for builtin type <class 'function'>". Could you please help me figure out how you go the signature to work.

PhilipTrauner commented 5 years ago

This is an inspect bug that was fixed by this commit. I suspect that you've been using Python 3.6 or an older version to execute the code snippets, which would explain why you ran into this issue. The problem should disappear if you upgrade to 3.7 🙂 (@Ankita10)