Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert one-element list to tuple in Python. #126234

Closed
kmrul opened this issue Oct 31, 2024 · 2 comments
Closed

Convert one-element list to tuple in Python. #126234

kmrul opened this issue Oct 31, 2024 · 2 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@kmrul
Copy link

kmrul commented Oct 31, 2024

Bug report

Bug description:

Input

tuple([1])

Expected output:

(1)

However, I got this:

(1,)

But for multiple element list convert to tuple is working fine.

CPython versions tested on:

3.9, 3.10, 3.11

Operating systems tested on:

Linux, macOS, Windows

@kmrul kmrul added the type-bug An unexpected behavior, bug, or error label Oct 31, 2024
@skirpichev
Copy link
Member

Expected output:

Sorry, but why you expect this output?! One-element tuples covered in many places of CPython docs, including the tutorial:
https://docs.python.org/3/tutorial/datastructures.html#tuples-and-sequences

@skirpichev skirpichev closed this as not planned Won't fix, can't repro, duplicate, stale Oct 31, 2024
@terryjreedy
Copy link
Member

Except for an empty tuple (()), commas, not parentheses, define a tuple, with 1 element tuple requiring a trailing comma.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants