From c2b3e8a93d9a3c46760d462f90eb2b12e49789e1 Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Sun, 18 Aug 2019 20:30:23 +0200 Subject: [PATCH] Add __len__ to Notifications --- diaspy/notifications.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/diaspy/notifications.py b/diaspy/notifications.py index cb5b42f..e958030 100644 --- a/diaspy/notifications.py +++ b/diaspy/notifications.py @@ -19,6 +19,9 @@ class Notifications(): self._notifications = self.get() self.page = 1 + def __len__(self): + return len(self._notifications) + def __iter__(self): return iter(self._notifications) @@ -39,7 +42,7 @@ class Notifications(): request = self._connection.get('notifications.json', headers=headers, params=params) if request.status_code != 200: - raise Exception('status code: {0}: cannot retreive notifications'.format(request.status_code)) + raise Exception('status code: {0}: cannot retrieve notifications'.format(request.status_code)) return self._finalise(request.json()) def _expand(self, new_notifications): -- 2.25.1