Indentation with Python

Asked by At

I don't understand why i'm getting an indentation error with that type of code. My function is inside a class and the indentation is "normal".

def SelectBarriere(self, NumShaker, B_Bar1, B_Bar2, B_Bar3):
    self.Lab_IMV = Label(self, "Configuration IMV:")
    self.Lab_IMV.move(1000, 250)
    self.BarIMVacc = BarPourcentage(self)
    self.BarIMVacc.move(1000,290)
    PoidBarriere1 = self.shakers[NumShaker, 14]
    PoidBarriere2 = self.shakers[NumShaker, 15]
    PoidBarriere3 = self.shakers[NumShaker, 16]
    if B_Bar1 == 2:
        self.MasseThermique = PoidBarriere1
    elif B_Bar2 == 2:
        self.MasseThermique = PoidBarriere2
    elif B_Bar3 == 2:
        self.MasseThermique = PoidBarriere3
    else:
        self.MasseThermique = 0
    return self.MasseThermique

The error come at this precise line.

PoidBarriere1 = self.shakers[NumShaker, 14]

2 Answers

0
lewis garton On Best Solutions

Python expects indentation to be consistent, tabs and spaces may be treated differently.

If you have copied some code the spacing may be different. Try the settings in your editor and enable the 'convert tabs to spaces' feature this will remove ambiguity between tabs and spaces by replacing tabs with a number of spaces.

0
Community On

Code looks fine to me. Maybe there is a tab instead of spaces?