I'm trying to take advantage of an external script's ability to perform list filtering faster than a multi-iteration loop within PAD. I have similar objects that I am comparing, each with an id property. If the "handled" list contains a matching ID to the "events" list, I want to remove that particular entry in the object. I've gotten this working in both plain JavaScript, as well as Python, but no matter what I do, I keep getting errors. The JavaScript compiler's error messages were too vague, so I switched to Python. In Python, I seem to be getting an error where the original JSON string's values are being stripped of its surrounding double quotes. This is causing Python interpreter errors. Am I handling this wrong?
Example of working Python, outside of PAD, (with most extraneous values removed for brevity):
events = [{"id":"11438923","title":"Event One"},{"id":"11362898","title":"Event Two"},{"id":"10734368","title":"Event Three"}]
handled = [{'id':'11438923'}]
# Extract the ids from the second object
handled_ids = set([obj['id'] for obj in handled])
# Filter out duplicates from the first object
events = [e for e in events if e['id'] not in handled_ids]
print(events)
The resulting list from the above code simply removes the first entry (matching the ID) from the events variable, and prints it out.
Although slightly adjusted from the above code, to handle how the values exist within my PAD flows, once run in PAD, the double-quoted strings for the object's values are seemingly gone. I can't even get past the assignment of the variable before an error is thrown. Immediately prior to entering the "Run Python script" action, if I display a Message Box with the content of the variable, the double-quotes exist.
Example input (JsonEvents variable, limited to one imported entry just to show its content) immediately prior to the Python action:
{"events":[{"id":"11438923","allday":"1","multiday":"1","private":"0","start":"1701406800","end":"1703393999","setup":"0","breakdown":"0","title":"Festive Fun with Felt: December Take-and-Make Craft Kits","description":"<p>Enjoy a seasonal take-and-make felt kit for December! Celebrate the start of winter and select one of three project options: Red Cardinal, Gingerbread House, or Knotted Tree. Each kit provides the pattern, directions, and materials to create and enjoy a festive felt craft. <\/p>\r\n\r\n<p>Pick up a free craft kit at the Library’s Information Desk any day this month! One kit per visit, please; available while supplies last.<\/p>","more_info":"<p>Free printable <a href=\"https:\/\/guides.sspl.org\/FeltFun\">directions and patterns for “Take and Make” kits<\/a> are always available online for current and past projects.<\/p>","url":"https:\/\/sspl.libcal.com\/event\/11438923","admin_url":"https:\/\/sspl.libcal.com\/aevent.php?c=10655&m=edit&event_id=11438923","location_id":"0","location":"","audience_id":"1604|1623|1627|1628","audience":"Children|Adults|Teens|All Ages","cat_id":"64132","category":"Art, Music, and Movies > Crafting","owner":"Kali Nagler","presenter":"Miriam Meier & Jasmine Gage","cal_id":"10655","calendar":"Library Events","color":"#B3C8EF","image":"https:\/\/lcimages.s3.amazonaws.com\/data\/feat_img\/4700\/10655\/1697730913.png","geo_id":"ChIJh9RRqdA53okR1XeeOfmgCng","geo_lat":null,"geo_long":null,"cost":"0","registration":"0","registration_open":"0","seats":"","seats_taken":null,"physical_seats":null,"physical_seats_taken":null,"online_seats":null,"online_seats_taken":null,"zoom_email":null,"online_user_id":null,"online_meeting_id":null,"online_host_url":null,"online_join_url":null,"online_join_password":null,"online_provider":null,"wait_list":"0","future_dates":null}]}
The Python interpreter error I get when I run the action:
File "", line 3
handled = { 'id': 11438923, 'allday': 1, 'multiday': 1, 'private': 0, 'start': 1701406800, 'end': 1703393999, 'setup': 0, 'breakdown': 0, 'title': Festive Fun with Felt: December Take-and-Make Craft Kits, 'description': <p>Enjoy a seasonal take-and-make felt kit for December! Celebrate the start of winter and select one of three project options: Red Cardinal, Gingerbread House, or Knotted Tree. Each kit provides the pattern, directions, and materials to create and enjoy a festive felt craft. </p>
^
SyntaxError: unexpected token 'Fun'
Ignoring the second variable for now, here are the two actions in the flow to cause the issue:

...and the content of the Python script:
events = %JsonEvents%
events = events['events']
handled = %HandledEventsTable%
# Extract the ids from the second object
handled_ids = set([h['id'] for h in handled])
# Filter out duplicates from the first object
events = [e for e in events if e['id'] not in handled_ids]
print(events)
Are there any thoughts as to what I might be missing here?