(Python 2.7.12)
I started writing some tests for Profile class and this came out:
When trying to invoke main() from Profile.py with just one line added at the end Profile(). Yes, an empty call. It does not error like in Python 3.x, it gives this output:
File "/home/ant6/PycharmProjects/beprof/beprof/profile.py", line 21, in __new__
new = super().__new__(cls, input_array, **meta)
TypeError: super() takes at least 1 argument (0 given)
Ok, let's read what people on Stack have to say... I changed this line to:
new = super(curve.Curve, cls).__new__(cls, input_array, **meta)
To give explicit class - for the record - we're in class Profile(curve.Curve).
Nope, still errors...
new = super(curve.Curve, cls).__new__(cls, input_array, **meta)
TypeError: an integer is required
So I then I tried putting Profile as super's argument... like this:
new = super(Profile).__new__(cls, input_array, **meta)
and got something on the very end of this class:
File "/home/ant6/PycharmProjects/beprof/beprof/profile.py", line 159, in __str__
ret = super().__str__()
TypeError: super() takes at least 1 argument (0 given)
at this point I just put ret = super(Profile).__str__() here. Well, now it seemed fine:
Traceback (most recent call last):
File "/home/ant6/PycharmProjects/beprof/beprof/profile.py", line 197, in <module>
main()
File "/home/ant6/PycharmProjects/beprof/beprof/profile.py", line 193, in main
Profile()
TypeError: __new__() takes at least 2 arguments (1 given)
TypeError, that is what we wanted. Or maybe expected it to be. But... now this goes totally wrong:
(Python 2.7.12) I started writing some tests for
Profile
class and this came out:When trying to invoke
main()
from Profile.py with just one line added at the endProfile()
. Yes, an empty call. It does not error like in Python 3.x, it gives this output:Ok, let's read what people on Stack have to say... I changed this line to:
To give explicit class - for the record - we're in
class Profile(curve.Curve)
. Nope, still errors...So I then I tried putting
Profile
as super's argument... like this:and got something on the very end of this class:
at this point I just put
ret = super(Profile).__str__()
here. Well, now it seemed fine:TypeError, that is what we wanted. Or maybe expected it to be. But... now this goes totally wrong:
gives:
or
if we use
ret = super(curve.Curve).__str__()
.It may look weird, but I when I wrote 'simple' call to Curve's
__str__
(ret = curve.Curve.__str__(self)
) - printing went well:Now it seems weird and all that but test pass on both Python 2.7.12 and Python 3.4 (I only have those two versions locally). You can see the diff here: https://github.com/ant6/beprof/commit/3df19431b8a365a6ad5161ec7a0e94d080d0f466
The question is - what should I do with this? Leave it with my little changes or?