我在 python 中工作以使用 GAE 构建 webapp。该项目最初是在没有 GAE 的情况下构建的,并且效果很好,然后我将这些文件带入 GAE 项目,突然之间它们不再那么好用了。一个文件 land.py 有 4 个代表不同土地类型的类,以及一个列表列表,其中包含每个类的多个实例。它们都基于land.py 文件中的土地类。
class Land():
def __init__(self):
self.elevation = 0
self.neighbors = []
self.creatures = []
self.location = (0, 0)
self.was = None#to keep track of when flooded
def __str__(self):
return("location " + str(self.location) +
" elevation " + str(self.elevation) +
" neighbors " + str(len(self.neighbors)) +
" creatures " + str(x.name for x in self.creatures) + " | ")
def redefine(self, land):
self.elevation = land.elevation
self.neighbors = land.neighbors
self.creatures = land.creatures
self.location = land.location
self.was = land
另一个类simulation.py进口土地,应该可以使用它,但是当我尝试
self.map = Land.landMass(the list of list's)
for row in self.map:
print(row)
它会打印'[,,,,,,,][,,,,,,,][,,,,,,,][,,,,,,,]'
它确实看到那里有物体,因为当我这样做时
for i in self.map:
for x in i:
output += x.__str__()
它打印每个陆地对象的正确输出。这是一个问题,因为当我想检查
for row in self.map:
for column in row:
if isinstance(land, Land.Water): #or type(land)
它首先不知道什么是土地,但它也知道什么是 Land.Water。如果您愿意,我可以提供代码,但很难准确找出问题所在。同样,在它自己的项目文件中它一切正常,但在 GAE 项目中却不行。有谁知道为什么?