KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I need to detect whether a function is an empty definition or not. It can be like: def foo(): pass or like: def foo(i, *arg, **kwargs): pass or like: foo = lambda x: None What is the most elegant way to detect them using the 'inspect' module? Is there a better way than this: def isEmptyFunction(func): e = lambda: None return func.__code__.co_code == e.__code__.co_code
Tags (comma-separated)
Save Edits
Cancel