33
44.. module :: tokenize
55 :synopsis: Lexical scanner for Python source code.
6-
6+ `
77**Source code:** :source: `Lib/tokenize.py`
88
99--------------
@@ -43,7 +43,7 @@ The primary entry point is a :term:`generator`:
4343 The generator produces :class: `TokenInfo ` objects.
4444
4545 .. versionchanged :: 3.1
46- Added support for named tuples.
46+ Changed to yield :class: ` TokenInfo ` objects instead of plain tuples.
4747
4848 :func: `.tokenize ` determines the source encoding of the file by looking for a
4949 UTF-8 BOM or encoding cookie, according to :pep: `263 `.
@@ -73,7 +73,7 @@ The primary entry point is a :term:`generator`:
7373
7474 .. attribute :: string
7575
76- The token text as a :class: `str `, usually as it appears in the source .
76+ The token text as a :class: `str `.
7777 For :data: `~token.STRING ` tokens, this includes the quotes, any prefix,
7878 and escape sequences, without evaluating them.
7979
@@ -95,24 +95,24 @@ The primary entry point is a :term:`generator`:
9595 .. attribute :: end
9696
9797 A 2-tuple ``(erow, ecol) `` of ints specifying the exclusive end
98- position of the token, using the same coordinate conventions as
99- :attr: ` start `. For a token spanning multiple lines, *erow * is the
100- final row and *ecol * is the column on that row.
98+ position of the token. Rows are numbered from 1 and columns from 0.
99+ For a token spanning multiple lines, *erow * is the final row and
100+ *ecol * is the column on that row.
101101
102102 For example, the name ``spam `` at the beginning of the first line
103103 has :attr: `start ` equal to ``(1, 0) `` and :attr: `end ` equal to ``(1, 4) ``.
104104
105105 For an :data: `~token.ENCODING ` token, this is ``(0, 0) ``.
106106 A :data: `~token.NEWLINE ` or :data: `~token.NL ` token inserted at the end
107- of input without a final newline can have an empty :attr: ` string `
108- and an end column one beyond the source text.
107+ of input without a final newline can have an end column one beyond
108+ the source text.
109109
110110 .. attribute :: line
111111
112- A :class: `str ` containing the full physical source line on which
112+ A :class: `str ` containing the full source line on which
113113 the token was found, including surrounding text and the line terminator
114114 if present. For a token spanning multiple lines, this can contain
115- several physical lines. It is empty for :data: `~token.ENCODING ` and
115+ several source lines. It is empty for :data: `~token.ENCODING ` and
116116 :data: `~token.ENDMARKER ` tokens.
117117
118118 .. attribute :: exact_type
@@ -125,6 +125,8 @@ The primary entry point is a :term:`generator`:
125125
126126 .. versionadded :: 3.3
127127
128+ .. versionadded :: 3.1
129+
128130
129131All constants from the :mod: `token ` module are also exported from
130132:mod: `!tokenize `.
0 commit comments