Message291665
> 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. |
|
Date |
User |
Action |
Args |
2017-04-14 14:42:56 | jdemeyer | set | recipients:
+ jdemeyer, scoder, steven.daprano |
2017-04-14 14:42:56 | jdemeyer | set | messageid: <1492180976.81.0.269048673882.issue30071@psf.upfronthosting.co.za> |
2017-04-14 14:42:56 | jdemeyer | link | issue30071 messages |
2017-04-14 14:42:56 | jdemeyer | create | |
|