Why is there no super().__init__() call when sub -classing backtrader objects?
jamespeterschinner last edited by jamespeterschinner
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 as
backtrackwould have been a nice name now that I consider it, but it was finally decided to go with
backtrader. 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 variant
super(self.__class__, self).__init__()) because it was decided that the base objects from which end users will subclass wouldn't have
You can still invoke
super().__init__(), but it will just go all the way up to the standard Python
object.__init__, which by itself does nothing.
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.
backtraderfeatures a metaclass-machinery which does all the work in the background. The documentation already states that those things are available.
jamespeterschinner last edited by
Thanks for the answer. I fixed the title from
backtrader. Yes, I have read the docs, I will read it again with this in mind. Ta