eepromというリストの特定の内容を受け取り、 bytesというリストの下に保存しようとしています。
class Parameter (object):
def __init__ (self, eeprom, *address):
self.eeprom = eeprom
self.bytes = list()
for a in address:
a = int(a, 16)
byte = eeprom[a] # here lies the problem
self.bytes.append(byte)
sthg = Parameter(eeprom, "0x00B9", "0x00BA")
スクリプトを実行するたびに、次のエラーが発生します。
TypeError: 'int' object has no attribute '__getitem__'
なぜこれが起こるのか誰にも分かりますか?これをインタープリターに書いた場合は機能しますが、このエラーが発生するのはモジュールとして実行した場合のみです。