2015-07-11 97 views
0

我想打破長的語句,如:Python的換行符 「以X1爲Y1,X2爲Y2,X3爲Y3」 聲明

with X1() as y1, X2() as y2, X3() as y3: # Really long line 
    # Do something 

我曾嘗試:

with (
    X1() as y1, 
    X2() as y2, 
    X3() as y3): 
    # Do something 

但這是一個語法錯誤。看來,以下的作品,但我發現它比較難讀:

with X1(
    ) as y1, X2(
    ) as y2, X3(
    ) as y3: 
    # Do something 

有沒有對如何最好地格式化長with聲明這樣有什麼建議?謝謝。

回答

相關問題