[Tutor] How arguments to the super() function works?

Mark Lawrence breamoreboy at gmail.com
Sat May 18 19:16:37 EDT 2019


On 18/05/2019 17:21, Arup Rakshit wrote:
> I am writing an Flask app following a book, where a piece of python concept I am not getting how it works. Code is:
> 
> class Role(db.Model):
>      __tablename__ = 'roles'
>      id = db.Column(db.Integer, primary_key=True)
>      name = db.Column(db.String(64), unique=True)
>      default = db.Column(db.Boolean, default=False, index=True)
>      permissions = db.Column(db.Integer)
>      users = db.relationship('User', backref='role', lazy='dynamic')
> 
>      def __init__(self, **kwargs):
>          super(Role, self).__init__(**kwargs)
>          if self.permissions is None:
>              self.permissions = 0
> 
> Here, why super(Role, self).__init__(**kwargs) is used instead of super().__init__(**kwargs) ? What that Role and self argument is instructing the super() ?
> 
> Thanks,
> 
> Arup Rakshit
> ar at zeit.io

Please check this https://www.youtube.com/watch?v=EiOglTERPEo out.  If 
that doesn't answer your question please ask again.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence



More information about the Tutor mailing list