errorLog= ErrorLog["Apple Computers needed, but no OS available"]
You used brackets. You need parentheses to create an object:
errorLog= ErrorLog("Apple Computers needed, but no OS available")
質問
Today, some unexpected behavior came up. When I wrote this:
class ErrorPost(object):
def __init__(self, message):
self.message = "[Error]" + message
print(self.message)
del self
class ErrorLog(ErrorPost):
def __init__(self, message):
super().__init__(message)
del self
This code throws an error, when creating an ErrorLog object:
TypeError: 'type' object is not subscriptable
Why is this? I am not manipulating the type of anything, and am not trying to make an object into another type, such as an int. What is happening, here?
I am limited on the amount of code I can post, sorry.
Full Stack Trace:
C:\Python33\python.exe C:/Users/******/Documents/MalwareTycoon/main.py
Traceback (most recent call last):
File "C:/Users/******/Documents/MalwareTycoon/main.py", line 151, in generate_network
********Dict[self.*********] = ***(self.available*****Dict[randint])
IndexError: list index out of range
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/******/Documents/MalwareTycoon/main.py", line 201, in <module>
Game = Game()
Image loaded: C:/Users/******/Documents/MalwareTycoon\images\background.PNG
File "C:/Users/******/Documents/MalwareTycoon/main.py", line 58, in __init__
self.computers = self.generate_network()
File "C:/Users/******/Documents/MalwareTycoon/main.py", line 153, in generate_network
errorLog= ErrorLog["Apple Computers needed, but no OS available"]
TypeError: 'type' object is not subscriptable
Process finished with exit code 1
解決
errorLog= ErrorLog["Apple Computers needed, but no OS available"]
You used brackets. You need parentheses to create an object:
errorLog= ErrorLog("Apple Computers needed, but no OS available")