Attribute trouble when instantiating a class in Python 2.7
March 13, 2013 3:10 PM Subscribe
I'm having maddening problems creating objects in Python. Details inside
This is the beginning of a class definition I'm using:
class popObj(object):
"""standalone class mainly holding list of binary trees and generation"""
def _init_(self):
#initializes two empty lists and a generation tracker
self.biTrees=[None]*POP
self.selectedTrees=[None]*POP
self.generation = 0
In the main module of the program, then, I call:
population=popObj()
I'm able to put objects into the list at population.biTrees[] with no problem. But when I try to do anything with population.selectedTrees or population.generation, I get this error:
AttributeError: 'popObj' object has no attribute 'selectedTrees'
What's going on? This is driving me nuts. I recognize that my class definition isn't very elegant, but I can figure out why some of the attributes don't exist.
This is the beginning of a class definition I'm using:
class popObj(object):
"""standalone class mainly holding list of binary trees and generation"""
def _init_(self):
#initializes two empty lists and a generation tracker
self.biTrees=[None]*POP
self.selectedTrees=[None]*POP
self.generation = 0
In the main module of the program, then, I call:
population=popObj()
I'm able to put objects into the list at population.biTrees[] with no problem. But when I try to do anything with population.selectedTrees or population.generation, I get this error:
AttributeError: 'popObj' object has no attribute 'selectedTrees'
What's going on? This is driving me nuts. I recognize that my class definition isn't very elegant, but I can figure out why some of the attributes don't exist.
Response by poster: Oh Jesus Christ I'm an idiot.
posted by COBRA! at 3:18 PM on March 13, 2013 [1 favorite]
posted by COBRA! at 3:18 PM on March 13, 2013 [1 favorite]
« Older Does anyone else *HATE* the dentist?? | Newbie-friendly South SF Bay area tattoo shop... Newer »
This thread is closed to new comments.
posted by BungaDunga at 3:15 PM on March 13, 2013