Skip to content

Files

Latest commit

 

History

History
22 lines (14 loc) · 480 Bytes

trailing-comma-tuple.md

File metadata and controls

22 lines (14 loc) · 480 Bytes

Pattern: Use of trailing comma tuple

Issue: -

Description

In Python, a tuple is actually created by the comma symbol, not by the parentheses. Unfortunately, one can actually create a tuple by misplacing a trailing comma, which can lead to potential weird bugs in your code. You should always use parentheses explicitly for creating a tuple

Example of incorrect code:

tuple_test = 1, 2,

Example of correct code:

tuple_test = (1, 2)