本文介绍了这是一个错误,还是我?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 大家好, 出于某种原因,以下情况不起作用: C级: TYPES = [无] DICT = {} 类型为类型: DICT.update([E]中的E的(E,类型)) 您怎么看?这是一个错误吗? 解决方案 您怎么看?这是一个错误吗? 不要使用这些名字......选择真的很差...... thingydingy = [无] my = {} for thingydingy: my.update([(E,dingaling)for E in [1]])br /> 打印我的 您怎么看?这是一个错误吗? 你不能在它的类声明 范围内访问类的类变量,因为类型的名称在完成课程 声明之后才受约束。 尝试: C级: TYPES = [无] DICT = {} 类型为C.TYPES: C.DICT.update((E,Type)for E in [1]) - Neil Cerutti< mr ***** **********@gmail.com> Arrgh!我讨厌制作它的错误。但是我想补充一点,Python的类声明的这个 属性只有在我认为它才会让我困扰 将使用类变量作为默认方法参数 值。幸运的是,我不经常想。 ;) - Neil Cerutti< mr *************** @ gmail.com> Hello all,For some reason, the following does not work :class C:TYPES = [None]DICT = {}for Type in TYPES:DICT.update((E,Type) for E in [1])What do you think? Is this a bug? 解决方案What do you think? Is this a bug?Do not use those names...really poor choice...thingydingy = [None]my = {}for dingaling in thingydingy:my.update([(E,dingaling ) for E in [1]])print myWhat do you think? Is this a bug?You cannot access a class''s class variables in it''s class-statementscope, since the name of the type is not bound until after the classstatement is completed.Try:class C:TYPES = [None]DICT = {}for Type in C.TYPES:C.DICT.update((E, Type) for E in [1])--Neil Cerutti <mr***************@gmail.com>Arrgh! I hate making the "its" error. But I wanted to add that thisproperty of Python''s class statement bothers me only when I think itwould be good to use class variables as default method argumentvalues. Luckily, I don''t think very often. ;)--Neil Cerutti <mr***************@gmail.com> 这篇关于这是一个错误,还是我?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!