Questions tagged «member-variables»

5
类和实例属性之间有什么区别?
之间是否有有意义的区别: class A(object): foo = 5 # some default value 与 class B(object): def __init__(self, foo=5): self.foo = foo 如果要创建很多实例,这两种样式在性能或空间要求上是否有差异?阅读代码时,您是否认为两种样式的含义有明显不同?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.