Why is there no super().__init__() call when sub -classing backtrader objects?
-
I don't understand why there is no super call in derived class'
__init__
method. It seems confusing when the examples start referencing attributes that haven't been defined such asself.data
-
backtrack
would have been a nice name now that I consider it, but it was finally decided to go withbacktrader
. Plus the domain for the former was taken (lack of consideration) by a railway company and the latter was fully free.There is no
super().__init__
(or the Python 2.7 generic variantsuper(self.__class__, self).__init__()
) because it was decided that the base objects from which end users will subclass wouldn't have__init__
.You can still invoke
super().__init__()
, but it will just go all the way up to the standard Pythonobject.__init__
, which by itself does nothing.@jamespeterschinner said in Why is there no super().__init__() call when sub -classing backtrack objects?:
It seems confusing when the examples start referencing attributes that haven't been defined such as self.data
The point is to have you typing less and not having to pass parameters back and forth and calling unneeded methods.
backtrader
features a metaclass-machinery which does all the work in the background. The documentation already states that those things are available. -
Thanks for the answer. I fixed the title from
backtrack
tobacktrader
. Yes, I have read the docs, I will read it again with this in mind. Ta