I have a file ("data/map1.map") that is a cPickle dump an object Template(). This object has a num_layers field.
Now let's say I have the following code, with DisplayMap.enter() as my entry point into my program (note - not complete code, just a portion of it:
Code:
import cPickle as pickle
class DisplayMap(Scene):
def enter(self):
tiles = Tilemap('data/map1.map')
tiles.display()
class Tilemap:
def __init__(self, filename):
f = file(filename)
self = pickle.load(f)
print "\nTest #1:", self.num_layers
def display(self):
print "\nTest #2:", self.num_layers
Why is it that Test #1 (found in Tilemap.__init__) responds correctly but test #2 (found in Tilemap.display) returns a AttributeError: Tilemap instance has no attribute 'num_layers'
Is it because self is referring to something else, and not the tilemap instance of Tilemap()? What would it be referring to?
Bookmarks