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
posted by COBRA! to computers & internet (2 answers total) 1 user marked this as a favorite
This is the beginning of a class definition I'm using:
"""standalone class mainly holding list of binary trees and generation"""
#initializes two empty lists and a generation tracker
self.generation = 0
In the main module of the program, then, I call:
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.