I've just started learning Python but have hit a little issue when instancing a class. I seem to get errors like:
AttributeError: type object 'Stuff' has no attribute 'a'
AttributeError: class 'Stuff' has no attribute 'a'
Clearly I'm missing something fairly fundamental :/
A quick test program shows what I mean:
class Stuff: def __init__(self): self.a = 0.02
def create(): x = Stuff y = Stuff z = Stuff a =  a.append(x) a.append(y) a.append(z) print a.a
I would have thought that the __init__ function would have initialised the elements of Stuff. If I add aline to asign a value to x.a then I get x, y, and z all with this same value. I appear to only creating one instance with my calls to Stuff rather than a new instance each. That or I really have no clue what I'm doing :)
On a side note I'm not really sure when Stuff(object) or Stuff should be in the class definition. But this is not something I've seen explained during my google-fu.
Edited by twoshots: n/a