79292266

Date: 2024-12-18 19:27:41
Score: 1.5
Natty:
Report link

Answer is in the comments as well. Thanks to:
https://stackoverflow.com/users/1766544/kenny-ostrom
https://stackoverflow.com/users/218663/jonsg

... for the help.

This was an instance of my misunderstanding how Python generators work. Switching to:

G[row['City1']][row['City2']]['shortPaths'] = list(shortPaths)

Works just fine.

I thought it was interesting how this example of my misunderstanding and learning about generators seemed to mimic a scope violation. Maybe a tip-off for others who find themselves struggling in a similar manner.

Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Blacklisted phrase (1): stackoverflow
  • No code block (0.5):
  • Self-answer (0.5):
  • High reputation (-1):
Posted by: Perry Horwich