[Python-ideas] PEP proposal: unifying function/method classes

Chris Angelico rosuav at gmail.com
Sun Mar 25 07:21:26 EDT 2018

On Sun, Mar 25, 2018 at 9:53 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> On Sun, Mar 25, 2018 at 06:52:09PM +1100, Chris Angelico wrote:
>> If people are checking "if type(x) is types.FunctionType", they're
>> doing it wrong.
> That depends on what "it" is that they're doing.
> If they want a callable, then they're doing it wrong.
> If they want a function regardless of whether it's written in Python or
> C or Cython, then they're doing it wrong.
> But if they *specifically* want a Python function, perhaps so they can
> pull it apart in ways you can't do to functions written in other
> languages, then it is fine.

My point was that checking if the type of something *is* some type
object, that's the wrong way to do things, and that a proper
isinstance check has other ways to solve the underlying problem.


More information about the Python-ideas mailing list