[Tutor] How arguments to the super() function works?
Arup Rakshit
ar at zeit.io
Sat May 18 12:21:39 EDT 2019
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
More information about the Tutor
mailing list