MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / tokenize

Function tokenize

tools/python-3.11.9-amd64/Lib/tokenize.py:408–430  ·  view source on GitHub ↗

The tokenize() generator requires one argument, readline, which must be a callable object which provides the same interface as the readline() method of built-in file objects. Each call to the function should return one line of input as bytes. Alternatively, readline can b

(readline)

Source from the content-addressed store, hash-verified

406
407
408def tokenize(readline):
409 """
410 The tokenize() generator requires one argument, readline, which
411 must be a callable object which provides the same interface as the
412 readline() method of built-in file objects. Each call to the function
413 should return one line of input as bytes. Alternatively, readline
414 can be a callable function terminating with StopIteration:
415 readline = open(myfile, 'rb').__next__ # Example of alternate readline
416
417 The generator produces 5-tuples with these members: the token type; the
418 token string; a 2-tuple (srow, scol) of ints specifying the row and
419 column where the token begins in the source; a 2-tuple (erow, ecol) of
420 ints specifying the row and column where the token ends in the source;
421 and the line on which the token was found. The line passed is the
422 physical line.
423
424 The first token sequence will always be an ENCODING token
425 which tells you which encoding was used to decode the bytes stream.
426 """
427 encoding, consumed = detect_encoding(readline)
428 empty = _itertools.repeat(b"")
429 rl_gen = _itertools.chain(consumed, iter(readline, b""), empty)
430 return _tokenize(rl_gen.__next__, encoding)
431
432
433def _tokenize(readline, encoding):

Callers 1

mainFunction · 0.70

Calls 4

repeatMethod · 0.80
chainMethod · 0.80
detect_encodingFunction · 0.70
_tokenizeFunction · 0.70

Tested by

no test coverage detected