Python class NameError name "xxx" is not defined

Python class NameError name "xxx" is not defined

这是因为在 class 中调用了带双下划线 "__" 的函数对象,例如:

def __fun():

  pass

class A():

  def __init__(self):

    __fun()  #会报错,不要调用外部带 __ 的函数

原文地址:https://www.cnblogs.com/ibingshan/p/10457430.html