import tensorflow as tf
...
with tf.Session() as sess:
output = sess.run(result)
print(output)
print(output)
Why does the last line work? Isn't output out of scope since it was declared inside the generator?
import tensorflow as tf
...
with tf.Session() as sess:
output = sess.run(result)
print(output)
print(output)
Why does the last line work? Isn't output out of scope since it was declared inside the generator?
In python with does not have scoping like methods, this post explains it more clearly
Variable defined with with-statement available outside of with-block?
To save you some time
the context manager will be available outside the with statement and that is not implementation or version dependent. with statements do not create a new execution scope.