私は新しいバージョンのPyCharmを使ってPythonを扱います。私はクラスの項目「未解決の属性参照
のための「ItemLocation」
未解決の属性参照を受けていますが、アプリケーションはエラーなしまたはクラッシュし、任意のアイデアと罰金起動しますか?
class Item: def __init__(self, state = '', location = '', realm = 'All', index =- 1): self.__dict__ = { 'ActiveState': state, 'ItemEquipped': 0, 'ItemLocation': location, # <-- DEFINED HERE 'ItemRealm': realm, 'ItemLevel': '51', 'ItemQuality': '100', 'ItemType': '', 'ItemName': '', 'ItemAFDPS': '', 'ItemSpeed': '', 'ItemBonus': '', 'ItemSource': '', 'LeftHand': '', 'ItemDamageType': '', 'ItemRestrictions': list(), 'ItemNotes': '', 'ItemRequirement': '', 'TemplateIndex': index, } self.ItemSlotList = list() if self.ItemLocation in SlotList['Jewelery']: # <-- HERE self.ActiveState = 'drop' self.ItemEquipped = 2 elif self.ItemLocation in SlotList['Armor']: # <-- HERE self.ActiveState = 'crafted' self.ItemEquipped = 2 elif self.ItemLocation in SlotList['Weapons']: # <-- HERE self.ActiveState = 'drop' self.ItemEquipped = 0 elif self.ItemLocation in SlotList['Mythical']: # <-- HERE self.ActiveState = 'drop' self.ItemEquipped = 2 # TODO: DETERMINE 'ItemEquipped' FOR WEAPONS BASED ON CLASS SELECTION self.ItemSlotList = self.makeItemSlots()
申し訳ありませんが、私はまだ学習しています。私はPython 3とPyQt5を実行しています
この未解決の属性参照を受け取っている状況は不明です。 –
'self .__ dict__'への割り当ては、逆です - 私はそれが許されても驚いています。あなたの '__init __()'でインスタンス変数を初期化する通常の方法は 'self.ActiveState = state'のような一連のステートメントです。 – jasonharper
私はこれを見て少しショックを受けていました。私は現在、完全な混乱であるアプリケーションを書き換えています。これは私が見たいくつかの例の1つに過ぎません。 –