0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Pythonの最悪なところ

Posted at

どう考えても意図していない文字列の連結

arr = [
    "line 1",
    "line 2"
    "line 3"
]
print(arr)
['line 1', 'line 2line 3']

誰が望んでるんだよこの挙動。最後の要素はカンマを付けても付けなくてもいいのになぜこんな挙動に?

分かりにくすぎるコンマ

x = very_long_method_name(very_long_argument1, very_long_argument2),
print(x)
(x,)

見逃しやすいコンマが加わっただけでタプルにするな。動的型だから実行時まで気づかないんじゃ。せめて括弧を要求しろ。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?