To be short, suppose I have a string 'next',
next = "123rpq"
and I can apply a str method .isdigit() to 'next'. So my question is how to check the implementation of this method. Hence is there a thing like inspect.getsource(somefunction) to get the source code of a ‘method’?
UPDATE: see comment about variable name 'next' below.
For modules, classes, functions and a few other objects you can use
inspect.getfileorinspect.getsourcefile. However, for builtin objects and methods this will result in aTypeError. As metioned by C0deH4cker, builtin objects and methods are implemented in C, so you will have to browse the C source code.isdigitis a method of the builtin string object, which is implemented in the fileunicodeobject.cin theObjectsdirectory of the Python source code. Thisisdigitmethod is implemented from line 11,416 of this file. See also my answer here to a similar but more general question.