TabError: inconsistent use of tabs and spaces in indication

Asked 2 years ago, Updated 2 years ago, 92 views

When trying to create a simple login form using Flask and Flask-wtf,

confirm_password=Password('Password', validators=[DataRequired(), EqualTo(')])
                                                                                   ^
TabError: inconsistent use of tabs and spaces in indication

An error similar to

occurred.

I understand that the error is caused by tabs and indentation, but no matter how many times I fix it, it looks like this. - will occur.

How can we solve this problem?Please give me an answer.
Below is the code where the error occurred.


from flash_wtf import FlashForm
from wtforms import StringField, PasswordField, SubmitField, BooleanField
from wtforms.validators import DataRequired, Length, Email

class RegistrationForm (FlaskForm):
    username=StringField('username', validators=[DataRequired(), Length(min=2, max=20)])

    email=StringField('Email', validators=[DataRequired(), Email()])

    password=PasswordField('Password', validators=[DataRequired()])

    confirm_password=Password('Password', validators=[DataRequired(), EqualTo(')])

    submit=SubmitField('Sign Up')

class LoginForm (FlaskForm):
    email=StringField('Email', validators=[DataRequired(), Email()])

    password=PasswordField('password', validators=[DataRequired()])

    remember=BooleanField('Remember Me')

    submit=SubmitField('Login')   


python flask

2022-09-30 17:17

1 Answers

TabError
Sent when using tabs and spaces for indentation in an inconsistent manner.
https://docs.python.jp/3/library/exceptions.html#TabError

This occurs when both tabs and spaces are used to indent the code.

However, as far as the source code is concerned, the tab does not appear to exist (Stack Overflow problem?).

  • Writing or copying tabs and spaces
    • confirm_password is mixed, so check and remove
  • If it does not appear to be mixed
    • The editor may be malfunctioning.Try using a different editor.
    • cat-e file|less allows you to view tabs as characters instead of spaces, and so on.
  • confirm_password is mixed, so check and remove
  • The editor may be malfunctioning.Try using a different editor.
  • cat-e file|less allows you to view tabs as characters instead of spaces, and so on.


2022-09-30 17:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.