Re: how to make super() work with externally defined methods in inheritance???

2018-08-15 Thread Paint-It-Black via Python-list
> # this prints for me when I run this in 3.6 

excuse me, that is an extraneous comment from a cut and paste, in fact the 
example never makes it to the prints, as shown in the transcript just below the 
source code
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to make super() work with externally defined methods in inheritance???

2018-08-15 Thread Paint-It-Black via Python-list
> ChrisA

Yes, that works.  Thank you all for your help.  -->


class A:
  def __init__(self):
self.number = 1

def A_biginc(self):
  self.number += 107

A.biginc = A_biginc

class B(A):
  def __init__(self):
super().__init__()
print("making a B")

def B_biginc(self):
  super(B,self).biginc() # super() trips up
  super(B,self).biginc()
  return self.number

B.biginc = B_biginc

def f_ut_oh():
   a = A()
   flag1 = a.number == 1
   a.biginc()
   flag2 = a.number == 108

   b = B()
   flag3 = b.number == 1
   b.biginc() 
   flag4 = b.number == 215

   if flag1 and flag2 and flag3 and flag4 :
 print("all good!") 
   else:
 print("hmm something went wrong..")

print("loaded try_adding_method.py")

>

Python 3.6.6 (default, Jun 27 2018, 14:44:17) 
[GCC 8.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> python.el: native completion setup loaded
>>> loaded try_adding_method.py
>>> f_ut_oh()
making a B
all good!
>>> 
-- 
https://mail.python.org/mailman/listinfo/python-list