Fix deprecations and super usage
All threads resolved!
All threads resolved!
Merge request reports
Activity
- Resolved by André Anjos
mentioned in commit 06a10a02
mentioned in merge request bob.bio.base!118 (merged)
29 29 The extension of raw data files, e.g. ``.png``. 30 30 """ 31 31 32 def __init__(self, original_directory, original_extension): @amohammadi Do you know what is the reason to put call to
super()
here when theFileDatabase
just extendsobject
? I get a complain thatobject.__init__() takes no parameters
That's how super works ...
class A(object): def __init__(self, A1, **kwargs): print('init of A is called with kwargs {}'.format(kwargs)) super(A, self).__init__(**kwargs) self.A1 = A1 class B(object): def __init__(self, B1, **kwargs): print('init of B is called with kwargs {}'.format(kwargs)) super(B, self).__init__(**kwargs) # <-- this will not call object.__init__ but it will call A.__init__ self.B1 = B1 class C(B, A): def __init__(self, **kwargs): print('init of C is called with kwargs {}'.format(kwargs)) super(C, self).__init__(**kwargs) c = C(A1='A1', B1='B1')
you will get:
init of C is called with kwargs {'A1': 'A1', 'B1': 'B1'} init of B is called with kwargs {'A1': 'A1'} init of A is called with kwargs {}
As you can see above
B
just extendsobject
but when super is used it will actually callA.__init__
without having to know about it. So you think B will call object but in reality it will call A when you have diamond shaped inheritance like here:object / \ / \ A B \ / \ / C
Edited by Amir MOHAMMADI@pkorshunov just make sure you don't pass extra arguments to this class if it is not really needed. You can see how I fixed this issue in bob.bio.base!118 (diffs)
Yes it is fixed in bob.bio.face
Edited by Amir MOHAMMADI
Please register or sign in to reply