0

Trying to understand the wonderful: https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-vii-error-handling i found this interesting line:

super(EditProfileForm, self).__init__(*args, **kwargs).

I suppose that we just call the parent class FlaskForm and the signature of the __init__ of this class is probably sommethnig like __init__(*args,**kwargs) and was wondering what was the purpose of including *args,**kwargs ...

Is this a way to let the users add any extra arguments later after inheriting ?

class EditProfileForm(FlaskForm):
    username = StringField('Username', validators=[DataRequired()])
    about_me = TextAreaField('About me', validators=[Length(min=0, max=140)])
    submit = SubmitField('Submit')

    def __init__(self, original_username, *args, **kwargs):
        super(EditProfileForm, self).__init__(*args, **kwargs)
        self.original_username = original_username

Barmar
  • 741,623
  • 53
  • 500
  • 612
curious
  • 201
  • 1
  • 10

0 Answers0