python error

the article records small errors I met when I use python, which reflects some easily-ignored python grammar .they all cost me some time to look for solutions on Google, StackOverflow and etc. I wish it will help someone with same issue :)

class Test:
    hello="class variable"
    hey = "hey class variable"

c1 = Test()
c2 = Test()
del c1.hello
print(Test.__dict__)

error

Traceback (most recent call last):
    del c1.hello
AttributeError: hello
[Finished in 0.2s with exit code 1]

reason
class variable reference can't be deleted via a instance

del Test.hello

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容