4

According to https://docs.python.org/3/library/functions.html, the "built-in function" means a python-innate function such as print or sum.

However, type(numpy.array) results in builtin_function_or_method even though the numpy module is not python-innate.

Why does it happen?

1 Answer 1

5

Because builtin_function_or_method is not really testing if it is a built in (which is rather a bit ambiguous term). Rather, it tests if a function or method was written in C.

From the official document:

types.BuiltinFunctionType

types.BuiltinMethodType

The type of built-in functions like len() or sys.exit(), and methods of built-in classes. (Here, the term “built-in” means “written in C”.)

Sign up to request clarification or add additional context in comments.

1 Comment

I haven't noticed that docs. Thank you :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.