最近在写udp socket程序时,对几个函数(如sendto)command+左击时,发现跳转到了这个python文件里面去了。(默认应该是到函数源码那里)
/PyCharm2018.1/python_stubs/160944109/_socket.py
定义了如下的伪函数
def send(self, data, flags=None): # real signature unknown; restored from __doc__
"""
send(data[, flags]) -> count
Send a data string to the socket. For the optional flags
argument, see the Unix manual. Return the number of bytes
sent; this may be less than len(data) if the network is busy.
"""
pass
def sendall(self, data, flags=None): # real signature unknown; restored from __doc__
"""
sendall(data[, flags])
Send a data string to the socket. For the optional flags
argument, see the Unix manual. This calls send() repeatedly
until all data is sent. If an error occurs, it's impossible
to tell how much data has been sent.
"""
pass
google了下,发现已经有人在stackoverflow提出相关问题,我这里简单提炼一下。
https://stackoverflow.com/questions/24266114/pycharm-what-is-python-stubs
什么情况下会出现跳转到python_stubs?
当我们调用的函数是内置函数或仅二进制存在的函数(没有py文件,只有pyc等)时,pycharm会对某个版本进行硬编码而生成的伪函数(实际不是调用的这个,只是方便我们做开发)。
想一想pycharm为了方便我们,真是煞费苦心。