Why can I use something like
import numpy as np
print( (g := np.arange(256)**2) / np.max(g) )
but the following fails?
foo = list(range(256))
for i in range( (l := len(foo)) // 16 + 0 if l%16 == 0 else 1 ):
print(i)
Traceback (most recent call last):
File "test.py", line 8, in <module>
for i in range( (l := len(foo)) // 16 + 0 if l%16 == 0 else 1 ):
NameError: name 'l' is not defined
l. Firstl%16 == 0is evaluated which fails.