M
MackS
I'm new to Python. In general I manage to understand what is happening
when things go wrong. However, the small program I am writing now fails
with the following message:
AttributeError: ClassA instance has no attribute '__len__'
Following the traceback,I see that the offending line is
self.x = arg1 + len(self.y) + 1
Why should this call to the built-in len() fail? In a small test
program it works with no problems:
class foo:
def __init__(self):
self.x = 0
self.y = 'y'
def fun(self, arg1):
self.x = arg1 + len(self.y) + 1
No problems; can you help me make some sense of what is happening?
Thanks in advance
Mack
when things go wrong. However, the small program I am writing now fails
with the following message:
AttributeError: ClassA instance has no attribute '__len__'
Following the traceback,I see that the offending line is
self.x = arg1 + len(self.y) + 1
Why should this call to the built-in len() fail? In a small test
program it works with no problems:
class foo:
def __init__(self):
self.x = 0
self.y = 'y'
def fun(self, arg1):
self.x = arg1 + len(self.y) + 1
No problems; can you help me make some sense of what is happening?
Thanks in advance
Mack