Reputation: 1275
can't get my class variables working properly,
class World:
def __init__(self, size):
self.size = size
self.grid = []
for i in range(0,size):
self.grid.append([])
for j in range(0,size):
self.grid[i].append(0)
def Display(self):
for row in self.grid:
print row
TheWorld = World(int(raw_input("Input world size(integer): ")))
TheWorld.Display
The problem is, the display function doesn't do anything, i think it's not referencing self.grid properly somehow. I input the world size as 0,10,100, doesn't make a difference. Any ideas ?? Thanks
Upvotes: 0
Views: 102
Reputation: 2991
Well that should be because you have not actually called the Display function. You have to say
TheWorld.Display()
for the function to be actually called.
Upvotes: 3
Reputation: 59674
This is not VBA. I have to call the function using ()
:
TheWorld = World(int(raw_input("Input world size(integer): ")))
TheWorld.Display()
Upvotes: 1
Reputation: 36735
You are not calling the function, you are merely referencing the function object. Try:
TheWorld.Display()
Upvotes: 8