An interesting topic was raised in the comments to the answer to the question .

The discussion began with whether list () can be considered a function. Or is the class constructor an absolutely separate entity that is not a function?

Then the question arose more generally - can any callable object be considered as a function or not?

It is clear that there are "real" functions for which type shows <type 'function'> , and there are other objects for which it does not show this. However, even for methods, it shows not <type 'function'> , but very much even <type 'instancemethod'> . So now - methods for functions not to consider?

I was sure that in python it is correct to call any called object as a function. But google did not give me any authoritative sources on this issue, only private opinions.

Can someone refer me to an authoritative source that covers this topic, or bring any valid argument on this issue?

  • I don’t write on the 3rd python, but I read that the instancemethod was abolished there. And there is only type <function>. But by and large this is the same thing. Instancemethod = function by instance - Alexander
  • @Alexander, now checked - produces <function> for the method taken from the class, and <method> for the method taken from the class instance. But the question is, after all, a little about it. About the type just had to say. - Xander
  • @ Alexander Python 3.7.2 gave me <class 'method'> , however - andreymal 8:43 pm
  • one
    (too many Alexandrov!) - andreymal
  • one
    In my opinion, the internal definition of a language does not change the essence. The instancemethod is the same function, but defined inside the class. Differences in type names serve mainly for specifics. But this is still a fragment of code that can be called from another code fragment. May or may not accept arguments, return or not return values - Nikita Umnov pm

0