Look at the python source code and find that all the functions in it end with pass, so what's the point?

for example:

class str(object):
    """
    str(object="") -> str
    str(bytes_or_buffer[, encoding[, errors]]) -> str
    
    Create a new string object from the given object. If encoding or
    errors is specified, then the object must expose a data buffer
    that will be decoded using the given encoding and error handler.
    Otherwise, returns the result of object.__str__() (if defined)
    or repr(object).
    encoding defaults to sys.getdefaultencoding().
    errors defaults to "strict".
    """


    def capitalize(self): -sharp real signature unknown; restored from __doc__
        """
        S.capitalize() -> str
        
        Return a capitalized version of S, i.e. make the first character
        have upper case and the rest lower case.
        """
        return ""
        


    def endswith(self, suffix, start=None, end=None): -sharp real signature unknown; restored from __doc__
        """
        S.endswith(suffix[, start[, end]]) -> bool
        
        Return True if S ends with the specified suffix, False otherwise.
        With optional start, test S beginning at that position.
        With optional end, stop comparing S at that position.
        suffix can also be a tuple of strings to try.
        """
        return False

False 
    def find(self, sub, start=None, end=None): -sharp real signature unknown; restored from __doc__
        """
        S.find(sub[, start[, end]]) -> int
        
        Return the lowest index in S where substring sub is found,
        such that sub is contained within S[start:end].  Optional
        arguments start and end are interpreted as in slice notation.
        
        Return -1 on failure.
        """
        return 0
0 

    def format(self, *args, **kwargs): -sharp known special case of str.format
        """
        S.format(*args, **kwargs) -> str
        
        Return a formatted version of S, using substitutions from args and kwargs.
        The substitutions are identified by braces ("{" and "}").
        """
        pass

pass


what I think now is: for these functions in this class, there is no logic in the function body? So how does the function work?

Apr.19,2021

some annotated interfaces are provided to users, telling them how to use them, while the source code is encrypted and protected, and the means of protection vary from person to person. Unless it is completely open source, you can't see the implementation code of some functions, and you can see some interface instructions at most.


python is implemented in C, and although many standard libraries are implemented in python code, the functions that support the underlying architecture are still C code. In order to give a friendly code hint to this, some IDE will use the same access interface as the underlying one, and its implementation will skip writing pass directly.

in addition, listening to the words "this user has no nickname" upstairs means that you can't see it because the source code is encrypted and protected, which is wrong. Cpython's code is open source.


this is not source code, but something similar to an "interface". You can only see what functions (methods) and parameters are here.


the underlying language is implemented in c, so the code doesn't really call the source code you posted.
but these sources are very useful because they show up when you help (str) . The goal is what each function does, a way to document through annotation reflection.
such as the function defined below

def func(a: int, b: str):
    return b * a

int and str have no effect, but when you use inspect.getfullargspec (func). Annotations , you can see the definition of each variable is the same, of course, the definition can be not only a class, but also a function, constant, and so on.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3eb8b-2b79c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3eb8b-2b79c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?