python中模块没有属性_python模块没有属性 (python module has no attribute)

2015-11-16 04:41:12

0

AttributeError: module 'actions' has no attribute 'MoveEast' keeps popping up in the terminal. I've tried renaming the functions and doing different importing methods like

from actions import Actions

but nothing happens.

import items, enemies, dungeon, player, actions

#rooms.py

#function in question

def adjacent_moves(self):

moves = []

if dungeon.room_exists(self.x + 1, self.y):

moves.append(actions.MoveEast())

if dungeon.room_exists(self.x - 1, self.y):

moves.append(actions.MoveWest())

if dungeon.room_exists(self.x, self.y - 1):

moves.append(actions.MoveNorth())

if dungeon.room_exists(self.x, self.y + 1):

moves.append(actions.MoveSouth())

return moves

#actions.py

class Actions:

def __init__(self, method, name, hotkey, **kwargs):

self.method = method

self.hotkey = hotkey

self.name - name

self.kwargs = kwargs

def MoveEast(Actions):

def __init__(self):

super().__init__(method=Player.move_right, name="Move Right", hotkey="r")

#from player.py

def move(self, dx, dy):

self.location_x += dx

self.location_y += dy

print(dungeon.room_exists(self.location_x, self.location_y).intro_text())

def move_right(self):

self.move(dx= 1, dy= 0)

你可能感兴趣的:(python中模块没有属性)