From 70472419e9e29968c637b96a9a253a564751e3ee Mon Sep 17 00:00:00 2001 From: Michael Rossetti Date: Sun, 25 Aug 2024 14:42:22 -0400 Subject: [PATCH] Update billboard.py --- billboard.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/billboard.py b/billboard.py index 271fe18..8ff939d 100644 --- a/billboard.py +++ b/billboard.py @@ -95,6 +95,21 @@ def __str__(self): else: return s + + def __iter__(self): + """Returns the entry as a dictionary. Uses snake case to conform to Python conventions. + Example: + dict(entry) + """ + yield 'title', self.title + yield 'artist', self.artist + yield 'image', self.image + yield 'peak_pos', self.peakPos + yield 'latest_pos', self.lastPos + yield 'weeks', self.weeks + yield 'rank', self.rank + yield 'is_new', self.isNew + def json(self): """Returns the entry as a JSON string. This is useful for caching.