D
Dustan
Looking at this interactive session:
def __init__(self, a):
self.a = a
def get_a(self): return self.__a
def set_a(self, new_a): self.__a = new_a
a = property(get_a, set_a)
b = property(get_a, set_a)
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
class B(A):
File "<pyshell#11>", line 2, in B
b = property(get_a, set_a)
NameError: name 'get_a' is not defined b = a
Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
class B(A):
File "<pyshell#13>", line 2, in B
b = a
NameError: name 'a' is not defined
B isn't recognizing its inheritence of A's methods get_a and set_a
during creation.
Why am I doing this? For an object of type B, it makes more sense to
reference the attribute 'b' than it does to reference the attribute
'a', even though they are the same, in terms of readability.
Is there any way to make this work as intended?
def __init__(self, a):
self.a = a
def get_a(self): return self.__a
def set_a(self, new_a): self.__a = new_a
a = property(get_a, set_a)
b = property(get_a, set_a)
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
class B(A):
File "<pyshell#11>", line 2, in B
b = property(get_a, set_a)
NameError: name 'get_a' is not defined b = a
Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
class B(A):
File "<pyshell#13>", line 2, in B
b = a
NameError: name 'a' is not defined
B isn't recognizing its inheritence of A's methods get_a and set_a
during creation.
Why am I doing this? For an object of type B, it makes more sense to
reference the attribute 'b' than it does to reference the attribute
'a', even though they are the same, in terms of readability.
Is there any way to make this work as intended?