PyCharm:如果__debug__]中无法访问的代码>

问题描述 投票:0回答:1

PyCharm对if __debug__:语句之类的代码中的代码说“ 此代码无法访问

”>
if __debug__:
    print("unreachable code is run")

正确到达并运行。

如果在该块中声明调试变量,这确实很烦人,因为PyCharm不会为它们自动完成。

这是错误还是配置混乱?有解决方法吗?

PyCharm对于__debug__:正确到达并运行的__debug__:语句(如if __debug__:print(“ unreachable code is run”))说,对于内部代码,“此代码不可访问”。这真是令人讨厌...

python pycharm
1个回答
0
投票

如果您在函数返回值后尝试运行代码,则代码将无法访问。例如:

def my_funk(x, y):
    return math.floor(x / y) #this function will break here.
    remainder = x - math.floor(x + y) * y # theis code is unreachable.
© www.soinside.com 2019 - 2024. All rights reserved.