class a(object):
def __init__(self):
self.b = 1
self.c = 2
This gives the error: NameError: name 'self' is not defined
I looked at a previous post, but the error was for a different reason. Any help with this?
class a(object):
def __init__(self):
self.b = 1
self.c = 2
This gives the error: NameError: name 'self' is not defined
I looked at a previous post, but the error was for a different reason. Any help with this?
I'm assuming the single space before def __init__(self): is actually a tab in your file and displayed as four spaces by your editor.
However python interprets a tab as 8 spaces, so the following two lines (which are indented by 8 spaces) are seen by python to be at the same level of indentation as the def.
This is exactly why you shouldn't mix tabs and spaces.