util.py で
class Stack:
"A container with a last-in-first-out (LIFO) queuing policy."
def __init__(self):
self.list = []
def push(self,item):
"Push 'item' onto the stack"
self.list.append(item)
def pop(self):
"Pop the most recently pushed item from the stack"
return self.list.pop()
def isEmpty(self):
"Returns true if the stack is empty"
return len(self.list) == 0
game.py で
class Directions:
NORTH = 'North'
SOUTH = 'South'
EAST = 'East'
WEST = 'West'
STOP = 'Stop'
LEFT = {NORTH: WEST,
SOUTH: EAST,
EAST: NORTH,
WEST: SOUTH,
STOP: STOP}
RIGHT = dict([(y,x) for x, y in LEFT.items()])
REVERSE = {NORTH: SOUTH,
SOUTH: NORTH,
EAST: WEST,
WEST: EAST,
STOP: STOP}
search.py で
from game import Directions
s = Directions.SOUTH
w = Directions.WEST
e = Directions.EAST
n = Directions.NORTH
from util import Stack
stack = Stack
stack.push(w)
stack.push(w) で「TypeError: unbound method push() must be called with Stack instance as first argument (got str instance instead)」というエラーが発生します。
これは正確にはどういう意味ですか?押せないw?もしそうなら、wをスタックにプッシュするにはどうすればよいですか?