Skip to content

5.3. Tuples and Sequences section should have the explanation of the indirect way of tuple comprehensions #135092

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

Open
hyperkai opened this issue Jun 3, 2025 · 2 comments
Assignees
Labels
docs Documentation in the Doc dir pending The issue will be closed if no feedback is provided

Comments

@hyperkai
Copy link

hyperkai commented Jun 3, 2025

5.3. Tuples and Sequences should have the explanation of the indirect way of tuple comprehensions as shown below:

Tuple comprehensions are not supported but if you really want them, do this with tuple() as shown below:

squares = tuple(x**2 for x in range(10))
@hyperkai hyperkai added the docs Documentation in the Doc dir label Jun 3, 2025
@skirpichev
Copy link
Contributor

Tuple comprehensions are not supported but if you really want them, do this with

Tuple docs says you can construct them from iterable, that means support for comprehensions: https://docs.python.org/3/library/stdtypes.html#tuple

Though, I don't see why this should be in the Tutorial. It doesn't mention even the tuple constructor.

@skirpichev skirpichev added the pending The issue will be closed if no feedback is provided label Jun 3, 2025
@rhettinger
Copy link
Contributor

squares = tuple(x**2 for x in range(10))

This is faster: tuple([x**2 for x in range(10)])

Though, I don't see why this should be in the Tutorial. It doesn't mention even the tuple constructor.

I agree.

@skirpichev skirpichev self-assigned this Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir pending The issue will be closed if no feedback is provided
Projects
Status: Todo
Development

No branches or pull requests

3 participants