Consider the following Python code:
class Test(object):
def __init__(self,name):
self.name = name
def __enter__(self):
return self
def __exit__(self,type,value,trace):
return True
t = Test("a")
with Test("b") as t:
print t.name
print t.name
I would have expected the output to be b,a, but it actually is b,b.
Is there no such thing as shadowing in Python? Is this really expected behavior?