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
最初の形式を許可することに関する実際的な問題はわかりません。これは、実装または論理を意味し、パーサーはコンマに問題があるべきではなく (あいまいではありません)、論理的な理由がわかりません。
http://docs.python.org/release/2.5/whatsnew/pep-343.html
http://www.python.org/dev/peps/pep-0343/は、これが単なる構文糖であることを示唆しています