Could you please explain, why this code works in Python 3.6
class B:
a = 'a_val'
b = {'a': 'a_val: {val}'.format(val=a)}
but this doesn't work?
class C:
a = 'a_val'
b = {i: 'a_val: {val}'.format(val=a) for i in range(0,2)}
NameError: name 'a' is not defined
and both classes work in Python 2.6.