The trick I use to avoid getting confused by these nested comprehensions is to expand the loop in the order it appears in the comprehension.
So in your example, you have a genex:
tag for tag in e['Tags'] for e in my_obj['Episodes']
Which you can mentally expand into double loop like this:
for tag in e['Tags']:
for e in my_obj['Episodes']:
yield tag
And now with this structure you can quite clearly see where your error lies, with e
being undefined, and see that it should really be:
for e in my_obj['Episodes']:
for tag in e['Tags']:
yield tag
Which collapses back into the nested comprehension
tag for e in my_obj['Episodes'] for tag in e['Tags']
As you have already seen from the previous answers. Hope this helps!