Indentation error in dictionary - Python

729 Views Asked by At

I created a dictionary in Python and keep getting an indentation error. I have checked all the spacing to make sure they are 4 spaces. The other questions similar to this one have all been problems with combining spaces and tabs, but I have used only spaces. I am not sure what it wrong. Please help! Thanks!

Here is the code:

class File:
def __init(self):
def open_files(self):
    for x in range(1,3):
        g = b[x]
        f = open(g, 'r')
        vals = f.read()
        f.close()
        vals = vals.split("\n")
        return vals
    mlats = []
    mlt,l = [], []
def get_ml(open_files):
    open_files(self)
    for x in range (0, len(vals)-1):
        tmp = vals[x]
        st = 6
        mlats.append(tmp[st:6+st])
        stx = 4
        sty = 14
        l. append(tmp[stx:stx+7])
        mlt.append(tmp[sty:sty+8])
        return l
        return mlt
    ls = []
def put_l(get_ml):
    get_ml(open_files)
    for x in range(35, len(mlt)-43):
        ls.append(l[x])
    mlts = []
def put_mlt(get_ml):
    get_ml(open_files)
    for x in range(35, len(mlt)-43):
        mlts.append(mlt[x])

And here is the error:

def open_files(self):
  ^
IndentationError: expected an indented block
1

There are 1 best solutions below

1
On

Your __init function should be __init__. And if you don't want that method to do any work, you should be more explicit and pass, or as @MartijnPieters mentioned you can just leave this method out entirely.

def __init__(self):
    pass