使用 Python 可以说:
a,b,c=something_that_returns_a_3_tuple()
但是这样的with
声明:
class thing(object):
def __enter__(self):
return (1,2,3)
def __exit__(self,a,b,c):
pass
with thing() as a,b,c:
print a
print b
print c
行不通
必须具备:
class thing(object):
def __enter__(self):
return (1,2,3)
def __exit__(self,a,b,c):
pass
with thing() as (a,b,c):
print a
print b
print c
我看不出允许第一种形式的实际问题,我的意思是实现或逻辑,解析器不应该有逗号问题(它不会模棱两可),我看不出有什么合乎逻辑的理由。