Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Confusing sentence in style.rst: "If you know the length of a list or tuple" #322

Copy link
Copy link
Closed
@AloisMahdal

Description

@AloisMahdal
Issue body actions

In style.rst, AKA "Coding style", the "Unpacking" section starts with quite a confusing sentence:

If you know the length of a list or tuple, you can assign names
to its elements with unpacking:

for index, item in enumerate(some_list):
    # do something with index and item

The author is apparently referring to the tuple returned by enumerate() built-in: we know its length is 2, so we can unpack it to 2 variables.

However, especially for reader new to Python, this might be confusing. The reader might assume that the list in question is some_list, but then what does this have to do with length?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.