On Mon, Mar 2, 2009 at 4:56 PM, Nick Mellor <nick.mellor.gro...@pobox.com> wrote: > Hi all, > > I'm pretty sure I'm following all the Python rules: I've put "self" > before "forename" to make sure it's treated as a data attribute > (instance variable.) And from within a class, I'm told, you need to > prefix the var with self too. RandomName is a class that I've tested > (and which still works.) So why do I get this error? > > File "h:\Testing\NameDb\dictfile.py", line 107, in randomName > return {"Forename" : self.forename.randomByWeight(), > AttributeError: RandomPerson instance has no attribute 'forename' > > Here's the code (Python 2.6, PythonWin): > > class RandomPerson: > def __init(self):
That previous line is supposed to be: def __init__(self): Note the trailing underscores. Cheers, Chris -- Shameless self-promotion: http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list