I am fairly new in Python. I think to rename objects like the classical
with open('filename','r') as f
...
is very handy and I would like to do the same with many other objects but it fails, for instance, in
dic={'a':1}
with dic as x
pass
with the error: AttributeError: __enter__
I would like to know why it works in the first example but not in the second one.
Thanks!