I'm trying to figure out how len()
is works when used inside Python class. Running this code results in the error shown, even though I added a __len__
overload and used @property
, following various advice from the Internet.
class Routes:
def __init__(self):
self._route_list = list()
def __len__(self):
return len(self._route_list)
@property
def route_list(self):
return self._route_list
@classmethod
def check_list(self):
if not self.route_list or len(self.route_list) == 0:
print('ERROR: no items to print!')
routes = Routes()
routes.check_list()
TypeError: object of type 'property' has no len()