Python complains that class instance is not defined - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Python complains that class instance is not defined (/thread-21105.html) |
Python complains that class instance is not defined - colt - Sep-14-2019 Hello. I have this code line: instruction = Instruction (byte)that generates the following error message: Quote:Traceback (most recent call last): Instruction code it is: class Instruction (object): def __init___(self, identifier_byte): #type: (byte) -> self.identifier_byte = identifier_byteSo, what I am fogetting? Thanks for the input. RE: Python complains that class instance is not defined - ichabod801 - Sep-14-2019 Where is the class statement relative to the line causing the error? It looks like the error line is in a function called main. If the class definition is not in the same file before main is called, that could cause the error. RE: Python complains that class instance is not defined - colt - Sep-16-2019 (Sep-14-2019, 12:54 AM)ichabod801 Wrote: Where is the class statement relative to the line causing the error? It looks like the error line is in a function called main. If the class definition is not in the same file before main is called, that could cause the error. Thanks, that was the issue (solved with an import). Nonetheless,now I am receiving a: Quote:Traceback (most recent call last): and line 22 it is the same! (since I added an import): instruction = Instruction (byte)from the class constructor: def __init___(self, identifier_byte): #type: (byte) -> self.identifier_byte = identifier_byteit seems that it takes a parameter for me. RE: Python complains that class instance is not defined - ichabod801 - Sep-17-2019 You have three underscores after 'init', not two, so it's not overriding the actual initializer from object. |