Skip to content

Artificial newlines show in the "line" attribute of tokens in the tokenizer module #105564

Description

@pablogsal

Example:

from tokenize import generate_tokens
from io import StringIO
import pprint
pprint.pprint(list(generate_tokens(StringIO('a').readline)))

prints:

[TokenInfo(type=1 (NAME), string='a', start=(1, 0), end=(1, 1), line='a\n'),
 TokenInfo(type=4 (NEWLINE), string='', start=(1, 1), end=(1, 2), line='a'),
 TokenInfo(type=0 (ENDMARKER), string='', start=(2, 0), end=(2, 0), line='')]

Linked PRs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions