Jeroen Demeyer added the comment:

> If inspect reports something is a duck, it should be an actual duck, not just 
> something that quacks.

The problem is that some Python packages (Sphinx and IPython for example) 
really need to know whether it quacks. And the only tool they have is 
inspect.isfunction(), so they use that. It's silly that every single package 
using inspect.isfunction() should be fixed. Better just fix 
inspect.isfunction().

>>> from types import SimpleNamespace
>>> x = SimpleNamespace(__code__=1, spam=2)
>>> '__code__' in dir(x)

Of course, you can always break stuff. User code is not supposed to invent new 
__dunder__ special names.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30071>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to