💾 Archived View for tris.fyi › pydoc › tokenize captured on 2023-04-26 at 13:32:42. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-01-29)

-=-=-=-=-=-=-

Back to module index

Go to module by name

tokenize

Tokenization help for Python programs.

tokenize(readline) is a generator that breaks a stream of bytes into
Python tokens.  It decodes the bytes according to PEP-0263 for
determining source file encoding.

It accepts a readline-like method which is called repeatedly to get the
next line of input (or b"" for EOF).  It generates 5-tuples with these
members:

    the token type (see token.py)
    the token (a string)
    the starting (row, column) indices of the token (a 2-tuple of ints)
    the ending (row, column) indices of the token (a 2-tuple of ints)
    the original line (string)

It is designed to match the working of the Python tokenizer exactly, except
that it produces COMMENT tokens for comments and gives type OP for all
operators.  Additionally, all token lists start with an ENCODING token
which tells you which encoding was used to decode the bytes stream.

Classes

StopTokenizing

with_traceback(...)

  Exception.with_traceback(tb) --
      set self.__traceback__ to tb and return self.
args = <attribute 'args' of 'BaseException' objects>

TextIOWrapper

Character and line based layer over a BufferedIOBase object, buffer.

encoding gives the name of the encoding that the stream will be
decoded or encoded with. It defaults to locale.getpreferredencoding(False).

errors determines the strictness of encoding and decoding (see
help(codecs.Codec) or the documentation for codecs.register) and
defaults to "strict".

newline controls how line endings are handled. It can be None, '',
'\n', '\r', and '\r\n'.  It works as follows:


  enabled. Lines in the input can end in '\n', '\r', or '\r\n', and
  these are translated into '\n' before being returned to the
  caller. If it is '', universal newline mode is enabled, but line
  endings are returned to the caller untranslated. If it has any of
  the other legal values, input lines are only terminated by the given
  string, and the line ending is returned to the caller untranslated.


  translated to the system default line separator, os.linesep. If
  newline is '' or '\n', no translation takes place. If newline is any
  of the other legal values, any '\n' characters written are translated
  to the given string.

If line_buffering is True, a call to flush is implied when a call to
write contains a newline character.
close(self, /)
detach(self, /)
fileno(self, /)
flush(self, /)
isatty(self, /)
read(self, size=-1, /)
readable(self, /)
readline(self, size=-1, /)
readlines(self, hint=-1, /)

  Return a list of lines from the stream.

  hint can be specified to control the number of lines read: no more
  lines will be read if the total size (in bytes/characters) of all
  lines so far exceeds hint.
reconfigure(self, /, *, encoding=None, errors=None, newline=None, line_buffering=None, write_through=None)

  Reconfigure the text stream with new parameters.

  This also does an implicit stream flush.
seek(self, cookie, whence=0, /)
seekable(self, /)
tell(self, /)
truncate(self, pos=None, /)
writable(self, /)
write(self, text, /)
writelines(self, lines, /)

  Write a list of lines to stream.

  Line separators are not added, so it is usual for each of the
  lines provided to have a line separator at the end.
buffer = <member 'buffer' of '_io.TextIOWrapper' objects>
closed = <attribute 'closed' of '_io.TextIOWrapper' objects>
encoding = <member 'encoding' of '_io.TextIOWrapper' objects>
errors = <attribute 'errors' of '_io.TextIOWrapper' objects>
line_buffering = <member 'line_buffering' of '_io.TextIOWrapper' objects>
name = <attribute 'name' of '_io.TextIOWrapper' objects>
newlines = <attribute 'newlines' of '_io.TextIOWrapper' objects>
write_through = <member 'write_through' of '_io.TextIOWrapper' objects>

TokenError

with_traceback(...)

  Exception.with_traceback(tb) --
      set self.__traceback__ to tb and return self.
args = <attribute 'args' of 'BaseException' objects>

TokenInfo

count(self, value, /)

  Return number of occurrences of value.
index(self, value, start=0, stop=9223372036854775807, /)

  Return first index of value.

  Raises ValueError if the value is not present.
end = _tuplegetter(3, 'Alias for field number 3')
  Alias for field number 3
exact_type = <property object at 0x7f75e32fa980>
line = _tuplegetter(4, 'Alias for field number 4')
  Alias for field number 4
start = _tuplegetter(2, 'Alias for field number 2')
  Alias for field number 2
string = _tuplegetter(1, 'Alias for field number 1')
  Alias for field number 1
type = _tuplegetter(0, 'Alias for field number 0')
  Alias for field number 0

Untokenizer

add_whitespace(self, start)
compat(self, token, iterable)
untokenize(self, iterable)

Functions

ISEOF

ISEOF(x)

ISNONTERMINAL

ISNONTERMINAL(x)

ISTERMINAL

ISTERMINAL(x)

any

any(*choices)

detect_encoding

detect_encoding(readline)


      The detect_encoding() function is used to detect the encoding that should
      be used to decode a Python source file.  It requires one argument, readline,
      in the same way as the tokenize() generator.

      It will call readline a maximum of twice, and return the encoding used
      (as a string) and a list of any lines (left as bytes) it has read in.

      It detects the encoding from the presence of a utf-8 bom or an encoding
      cookie as specified in pep-0263.  If both a bom and a cookie are present,
      but disagree, a SyntaxError will be raised.  If the encoding cookie is an
      invalid charset, raise a SyntaxError.  Note that if a utf-8 bom is found,
      'utf-8-sig' is returned.

      If no encoding is specified, then the default of 'utf-8' will be returned.
    

generate_tokens

generate_tokens(readline)

  Tokenize a source reading Python code as unicode strings.

      This has the same API as tokenize(), except that it expects the *readline*
      callable to return str objects instead of bytes.
    

group

group(*choices)

lookup

lookup(encoding, /)

  Looks up a codec tuple in the Python codec registry and returns a CodecInfo object.

main

main()

maybe

maybe(*choices)

open

open(filename)

  Open a file in read only mode using the encoding detected by
      detect_encoding().
    

tokenize

tokenize(readline)


      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 be a callable function terminating with StopIteration:
          readline = open(myfile, 'rb').__next__  # Example of alternate readline

      The generator produces 5-tuples with these members: the token type; the
      token string; a 2-tuple (srow, scol) of ints specifying the row and
      column where the token begins in the source; a 2-tuple (erow, ecol) of
      ints specifying the row and column where the token ends in the source;
      and the line on which the token was found.  The line passed is the
      physical line.

      The first token sequence will always be an ENCODING token
      which tells you which encoding was used to decode the bytes stream.
    

untokenize

untokenize(iterable)

  Transform tokens back into Python source code.
      It returns a bytes object, encoded using the ENCODING
      token, which is the first token sequence output by tokenize.

      Each element returned by the iterable must be a token sequence
      with at least two elements, a token number and token value.  If
      only two tokens are passed, the resulting output is poor.

      Round-trip invariant for full input:
          Untokenized source will match input source exactly

      Round-trip invariant for limited input:
          # Output bytes will tokenize back to the input
          t1 = [tok[:2] for tok in tokenize(f.readline)]
          newcode = untokenize(t1)
          readline = BytesIO(newcode).readline
          t2 = [tok[:2] for tok in tokenize(readline)]
          assert t1 == t2
    

Other members

AMPER = 19
AMPEREQUAL = 41
ASYNC = 56
AT = 49
ATEQUAL = 50
AWAIT = 55
BOM_UTF8 = b'\xef\xbb\xbf'
Binnumber = '0[bB](?:_?[01])+'
CIRCUMFLEX = 32
CIRCUMFLEXEQUAL = 43
COLON = 11
COLONEQUAL = 53
COMMA = 12
COMMENT = 61
Comment = '#[^\\r\\n]*'
ContStr = '((|Rf|u|b|rb|r|BR|rf|fR|br|B|rB|f|RB|Fr|U|rF|Br|R|bR|Rb|fr|F|FR|RF)\'[^\\n\'\\\\]*(?:\\\\.[^\\n\'\\\\]*)*(\'|\\\\\\r?\\n)|(|Rf|u|b|rb|r|BR|rf|fR|br|B|rB|f|RB|Fr|U|rF|Br|R|bR|Rb|fr|F|FR|RF)"[^\\n"\\\\]*(?:\\\\.[^\\n"\\\\]*)*("|\\\\\\r?\\n))'
DEDENT = 6
DOT = 23
DOUBLESLASH = 47
DOUBLESLASHEQUAL = 48
DOUBLESTAR = 35
DOUBLESTAREQUAL = 46
Decnumber = '(?:0(?:_?0)*|[1-9](?:_?[0-9])*)'
Double = '[^"\\\\]*(?:\\\\.[^"\\\\]*)*"'
Double3 = '[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""'
ELLIPSIS = 52
ENCODING = 63
ENDMARKER = 0
EQEQUAL = 27
EQUAL = 22
ERRORTOKEN = 60
EXACT_TOKEN_TYPES = {'!=': 28, '%': 24, '%=': 40, '&': 19, '&=': 41, '(': 7, ')': 8, '*': 16, '**': 35, '**=': 46, '*=': 38, '+': 14, '+=': 36, ',': 12, '-': 15, '-=': 37, '->': 51, '.': 23, '...': 52, '/': 17, '//': 47, '//=': 48, '/=': 39, ':': 11, ':=': 53, ';': 13, '<': 20, '<<': 33, '<<=': 44, '<=': 29, '=': 22, '==': 27, '>': 21, '>=': 30, '>>': 34, '>>=': 45, '@': 49, '@=': 50, '[': 9, ']': 10, '^': 32, '^=': 43, '{': 25, '|': 18, '|=': 42, '}': 26, '~': 31}
Expfloat = '[0-9](?:_?[0-9])*[eE][-+]?[0-9](?:_?[0-9])*'
Exponent = '[eE][-+]?[0-9](?:_?[0-9])*'
Floatnumber = '(([0-9](?:_?[0-9])*\\.(?:[0-9](?:_?[0-9])*)?|\\.[0-9](?:_?[0-9])*)([eE][-+]?[0-9](?:_?[0-9])*)?|[0-9](?:_?[0-9])*[eE][-+]?[0-9](?:_?[0-9])*)'
Funny = '(\\r?\\n|(\\~|\\}|\\|=|\\||\\{|\\^=|\\^|\\]|\\[|@=|@|>>=|>>|>=|>|==|=|<=|<<=|<<|<|;|:=|:|/=|//=|//|/|\\.\\.\\.|\\.|\\->|\\-=|\\-|,|\\+=|\\+|\\*=|\\*\\*=|\\*\\*|\\*|\\)|\\(|\\&=|\\&|%=|%|!=))'
GREATER = 21
GREATEREQUAL = 30
Hexnumber = '0[xX](?:_?[0-9a-fA-F])+'
INDENT = 5
Ignore = '[ \\f\\t]*(\\\\\\r?\\n[ \\f\\t]*)*(#[^\\r\\n]*)?'
Imagnumber = '([0-9](?:_?[0-9])*[jJ]|(([0-9](?:_?[0-9])*\\.(?:[0-9](?:_?[0-9])*)?|\\.[0-9](?:_?[0-9])*)([eE][-+]?[0-9](?:_?[0-9])*)?|[0-9](?:_?[0-9])*[eE][-+]?[0-9](?:_?[0-9])*)[jJ])'
Intnumber = '(0[xX](?:_?[0-9a-fA-F])+|0[bB](?:_?[01])+|0[oO](?:_?[0-7])+|(?:0(?:_?0)*|[1-9](?:_?[0-9])*))'
LBRACE = 25
LEFTSHIFT = 33
LEFTSHIFTEQUAL = 44
LESS = 20
LESSEQUAL = 29
LPAR = 7
LSQB = 9
MINEQUAL = 37
MINUS = 15
NAME = 1
NEWLINE = 4
NL = 62
NOTEQUAL = 28
NT_OFFSET = 256
NUMBER = 2
N_TOKENS = 64
Name = '\\w+'
Number = '(([0-9](?:_?[0-9])*[jJ]|(([0-9](?:_?[0-9])*\\.(?:[0-9](?:_?[0-9])*)?|\\.[0-9](?:_?[0-9])*)([eE][-+]?[0-9](?:_?[0-9])*)?|[0-9](?:_?[0-9])*[eE][-+]?[0-9](?:_?[0-9])*)[jJ])|(([0-9](?:_?[0-9])*\\.(?:[0-9](?:_?[0-9])*)?|\\.[0-9](?:_?[0-9])*)([eE][-+]?[0-9](?:_?[0-9])*)?|[0-9](?:_?[0-9])*[eE][-+]?[0-9](?:_?[0-9])*)|(0[xX](?:_?[0-9a-fA-F])+|0[bB](?:_?[01])+|0[oO](?:_?[0-7])+|(?:0(?:_?0)*|[1-9](?:_?[0-9])*)))'
OP = 54
Octnumber = '0[oO](?:_?[0-7])+'
PERCENT = 24
PERCENTEQUAL = 40
PLUS = 14
PLUSEQUAL = 36
PlainToken = '((([0-9](?:_?[0-9])*[jJ]|(([0-9](?:_?[0-9])*\\.(?:[0-9](?:_?[0-9])*)?|\\.[0-9](?:_?[0-9])*)([eE][-+]?[0-9](?:_?[0-9])*)?|[0-9](?:_?[0-9])*[eE][-+]?[0-9](?:_?[0-9])*)[jJ])|(([0-9](?:_?[0-9])*\\.(?:[0-9](?:_?[0-9])*)?|\\.[0-9](?:_?[0-9])*)([eE][-+]?[0-9](?:_?[0-9])*)?|[0-9](?:_?[0-9])*[eE][-+]?[0-9](?:_?[0-9])*)|(0[xX](?:_?[0-9a-fA-F])+|0[bB](?:_?[01])+|0[oO](?:_?[0-7])+|(?:0(?:_?0)*|[1-9](?:_?[0-9])*)))|(\\r?\\n|(\\~|\\}|\\|=|\\||\\{|\\^=|\\^|\\]|\\[|@=|@|>>=|>>|>=|>|==|=|<=|<<=|<<|<|;|:=|:|/=|//=|//|/|\\.\\.\\.|\\.|\\->|\\-=|\\-|,|\\+=|\\+|\\*=|\\*\\*=|\\*\\*|\\*|\\)|\\(|\\&=|\\&|%=|%|!=))|((|Rf|u|b|rb|r|BR|rf|fR|br|B|rB|f|RB|Fr|U|rF|Br|R|bR|Rb|fr|F|FR|RF)\'[^\\n\'\\\\]*(?:\\\\.[^\\n\'\\\\]*)*\'|(|Rf|u|b|rb|r|BR|rf|fR|br|B|rB|f|RB|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= '[ \\f\\t]*'
blank_re = re.compile(b'^[ \\t\\f]*(?:[#\\r\\n]|$)', re.ASCII)
cookie_re = re.compile('^[ \\t\\f]*#.*?coding[:=][ \\t]*([-\\w.]+)', re.ASCII)
endpats = {"'": "[^'\\\\]*(?:\\\\.[^'\\\\]*)*'", '"': '[^"\\\\]*(?:\\\\.[^"\\\\]*)*"', "'''": "[^'\\\\]*(?:(?:\\\\.|'(?!''))[^'\\\\]*)*'''", '"""': '[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""', "Rf'": "[^'\\\\]*(?:\\\\.[^'\\\\]*)*'", 'Rf"': '[^"\\\\]*(?:\\\\.[^"\\\\]*)*"', "Rf'''": "[^'\\\\]*(?:(?:\\\\.|'(?!''))[^'\\\\]*)*'''", 'Rf"""': '[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""', "u'": "[^'\\\\]*(?:\\\\.[^'\\\\]*)*'", 'u"': '[^"\\\\]*(?:\\\\.[^"\\\\]*)*"', "u'''": "[^'\\\\]*(?:(?:\\\\.|'(?!''))[^'\\\\]*)*'''", 'u"""': '[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""', "b'": "[^'\\\\]*(?:\\\\.[^'\\\\]*)*'", 'b"': '[^"\\\\]*(?:\\\\.[^"\\\\]*)*"', "b'''": "[^'\\\\]*(?:(?:\\\\.|'(?!''))[^'\\\\]*)*'''", 'b"""': '[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""', "rb'": "[^'\\\\]*(?:\\\\.[^'\\\\]*)*'", 'rb"': '[^"\\\\]*(?:\\\\.[^"\\\\]*)*"', "rb'''": "[^'\\\\]*(?:(?:\\\\.|'(?!''))[^'\\\\]*)*'''", 'rb"""': '[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""', "r'": "[^'\\\\]*(?:\\\\.[^'\\\\]*)*'", 'r"': '[^"\\\\]*(?:\\\\.[^"\\\\]*)*"', "r'''": "[^'\\\\]*(?:(?:\\\\.|'(?!''))[^'\\\\]*)*'''", 'r"""': '[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""', "BR'": "[^'\\\\]*(?:\\\\.[^'\\\\]*)*'", 'BR"': '[^"\\\\]*(?:\\\\.[^"\\\\]*)*"', "BR'''": "[^'\\\\]*(?:(?:\\\\.|'(?!''))[^'\\\\]*)*'''", 'BR"""': '[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""', "rf'": "[^'\\\\]*(?:\\\\.[^'\\\\]*)*'", 'rf"': '[^"\\\\]*(?:\\\\.[^"\\\\]*)*"', "rf'''": "[^'\\\\]*(?:(?:\\\\.|'(?!''))[^'\\\\]*)*'''", 'rf"""': '[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""', "fR'": "[^'\\\\]*(?:\\\\.[^'\\\\]*)*'", 'fR"': '[^"\\\\]*(?:\\\\.[^"\\\\]*)*"', "fR'''": "[^'\\\\]*(?:(?:\\\\.|'(?!''))[^'\\\\]*)*'''", 'fR"""': '[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""', "br'": "[^'\\\\]*(?:\\\\.[^'\\\\]*)*'", 'br"': '[^"\\\\]*(?:\\\\.[^"\\\\]*)*"', "br'''": "[^'\\\\]*(?:(?:\\\\.|'(?!''))[^'\\\\]*)*'''", 'br"""': '[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""', "B'": "[^'\\\\]*(?:\\\\.[^'\\\\]*)*'", 'B"': '[^"\\\\]*(?:\\\\.[^"\\\\]*)*"', "B'''": "[^'\\\\]*(?:(?:\\\\.|'(?!''))[^'\\\\]*)*'''", 'B"""': '[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""', "rB'": "[^'\\\\]*(?:\\\\.[^'\\\\]*)*'", 'rB"': '[^"\\\\]*(?:\\\\.[^"\\\\]*)*"', "rB'''": "[^'\\\\]*(?:(?:\\\\.|'(?!''))[^'\\\\]*)*'''", 'rB"""': '[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""', "f'": "[^'\\\\]*(?:\\\\.[^'\\\\]*)*'", 'f"': '[^"\\\\]*(?:\\\\.[^"\\\\]*)*"', "f'''": "[^'\\\\]*(?:(?:\\\\.|'(?!''))[^'\\\\]*)*'''", 'f"""': '[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""', "RB'": "[^'\\\\]*(?:\\\\.[^'\\\\]*)*'", 'RB"': '[^"\\\\]*(?:\\\\.[^"\\\\]*)*"', "RB'''": "[^'\\\\]*(?:(?:\\\\.|'(?!''))[^'\\\\]*)*'''", 'RB"""': '[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""', "Fr'": "[^'\\\\]*(?:\\\\.[^'\\\\]*)*'", 'Fr"': '[^"\\\\]*(?:\\\\.[^"\\\\]*)*"', "Fr'''": "[^'\\\\]*(?:(?:\\\\.|'(?!''))[^'\\\\]*)*'''", 'Fr"""': '[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""', "U'": "[^'\\\\]*(?:\\\\.[^'\\\\]*)*'", 'U"': '[^"\\\\]*(?:\\\\.[^"\\\\]*)*"', "U'''": "[^'\\\\]*(?:(?:\\\\.|'(?!''))[^'\\\\]*)*'''", 'U"""': '[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""', "rF'": "[^'\\\\]*(?:\\\\.[^'\\\\]*)*'", 'rF"': '[^"\\\\]*(?:\\\\.[^"\\\\]*)*"', "rF'''": "[^'\\\\]*(?:(?:\\\\.|'(?!''))[^'\\\\]*)*'''", 'rF"""': '[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""', "Br'": "[^'\\\\]*(?:\\\\.[^'\\\\]*)*'", 'Br"': '[^"\\\\]*(?:\\\\.[^"\\\\]*)*"', "Br'''": "[^'\\\\]*(?:(?:\\\\.|'(?!''))[^'\\\\]*)*'''", 'Br"""': '[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""', "R'": "[^'\\\\]*(?:\\\\.[^'\\\\]*)*'", 'R"': '[^"\\\\]*(?:\\\\.[^"\\\\]*)*"', "R'''": "[^'\\\\]*(?:(?:\\\\.|'(?!''))[^'\\\\]*)*'''", 'R"""': '[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""', "bR'": "[^'\\\\]*(?:\\\\.[^'\\\\]*)*'", 'bR"': '[^"\\\\]*(?:\\\\.[^"\\\\]*)*"', "bR'''": "[^'\\\\]*(?:(?:\\\\.|'(?!''))[^'\\\\]*)*'''", 'bR"""': '[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""', "Rb'": "[^'\\\\]*(?:\\\\.[^'\\\\]*)*'", 'Rb"': '[^"\\\\]*(?:\\\\.[^"\\\\]*)*"', "Rb'''": "[^'\\\\]*(?:(?:\\\\.|'(?!''))[^'\\\\]*)*'''", 'Rb"""': '[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""', "fr'": "[^'\\\\]*(?:\\\\.[^'\\\\]*)*'", 'fr"': '[^"\\\\]*(?:\\\\.[^"\\\\]*)*"', "fr'''": "[^'\\\\]*(?:(?:\\\\.|'(?!''))[^'\\\\]*)*'''", 'fr"""': '[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""', "F'": "[^'\\\\]*(?:\\\\.[^'\\\\]*)*'", 'F"': '[^"\\\\]*(?:\\\\.[^"\\\\]*)*"', "F'''": "[^'\\\\]*(?:(?:\\\\.|'(?!''))[^'\\\\]*)*'''", 'F"""': '[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""', "FR'": "[^'\\\\]*(?:\\\\.[^'\\\\]*)*'", 'FR"': '[^"\\\\]*(?:\\\\.[^"\\\\]*)*"', "FR'''": "[^'\\\\]*(?:(?:\\\\.|'(?!''))[^'\\\\]*)*'''", 'FR"""': '[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""', "RF'": "[^'\\\\]*(?:\\\\.[^'\\\\]*)*'", 'RF"': '[^"\\\\]*(?:\\\\.[^"\\\\]*)*"', "RF'''": "[^'\\\\]*(?:(?:\\\\.|'(?!''))[^'\\\\]*)*'''", 'RF"""': '[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""'}
single_quoted = {'Rf"', "Rf'", 'RF"', "bR'", "rB'", 'f"', "U'", "R'", "'", "b'", 'FR"', "fR'", 'bR"', 'R"', "F'", "br'", "Br'", "RB'", 'rb"', 'Rb"', 'rf"', 'u"', 'rF"', "f'", "rf'", 'BR"', 'B"', 'Fr"', 'br"', "RF'", "FR'", 'b"', 'r"', "B'", 'F"', 'Br"', 'RB"', "fr'", 'rB"', 'U"', "r'", 'fR"', '"', "Fr'", "Rb'", "u'", "BR'", "rF'", "rb'", 'fr"'}
t = 'RF'
tabsize = 8
tok_name = {0: 'ENDMARKER', 1: 'NAME', 2: 'NUMBER', 3: 'STRING', 4: 'NEWLINE', 5: 'INDENT', 6: 'DEDENT', 7: 'LPAR', 8: 'RPAR', 9: 'LSQB', 10: 'RSQB', 11: 'COLON', 12: 'COMMA', 13: 'SEMI', 14: 'PLUS', 15: 'MINUS', 16: 'STAR', 17: 'SLASH', 18: 'VBAR', 19: 'AMPER', 20: 'LESS', 21: 'GREATER', 22: 'EQUAL', 23: 'DOT', 24: 'PERCENT', 25: 'LBRACE', 26: 'RBRACE', 27: 'EQEQUAL', 28: 'NOTEQUAL', 29: 'LESSEQUAL', 30: 'GREATEREQUAL', 31: 'TILDE', 32: 'CIRCUMFLEX', 33: 'LEFTSHIFT', 34: 'RIGHTSHIFT', 35: 'DOUBLESTAR', 36: 'PLUSEQUAL', 37: 'MINEQUAL', 38: 'STAREQUAL', 39: 'SLASHEQUAL', 40: 'PERCENTEQUAL', 41: 'AMPEREQUAL', 42: 'VBAREQUAL', 43: 'CIRCUMFLEXEQUAL', 44: 'LEFTSHIFTEQUAL', 45: 'RIGHTSHIFTEQUAL', 46: 'DOUBLESTAREQUAL', 47: 'DOUBLESLASH', 48: 'DOUBLESLASHEQUAL', 49: 'AT', 50: 'ATEQUAL', 51: 'RARROW', 52: 'ELLIPSIS', 53: 'COLONEQUAL', 54: 'OP', 55: 'AWAIT', 56: 'ASYNC', 57: 'TYPE_IGNORE', 58: 'TYPE_COMMENT', 59: 'SOFT_KEYWORD', 60: 'ERRORTOKEN', 61: 'COMMENT', 62: 'NL', 63: 'ENCODING', 64: 'N_TOKENS', 256: 'NT_OFFSET'}
triple_quoted = {'Fr"""', 'rF"""', "U'''", 'b"""', "Rf'''", "b'''", "rb'''", "rf'''", "fR'''", 'u"""', 'RB"""', '"""', "RF'''", "bR'''", "RB'''", "Br'''", 'Rb"""', 'rb"""', "rB'''", 'R"""', 'r"""', "u'''", "Rb'''", "r'''", 'B"""', "R'''", "F'''", "Fr'''", 'RF"""', "f'''", 'Rf"""', "BR'''", "fr'''", 'FR"""', 'br"""', "br'''", "FR'''", "'''", 'rB"""', 'fR"""', 'fr"""', 'f"""', 'U"""', 'F"""', 'Br"""', 'rf"""', "rF'''", 'BR"""', "B'''", 'bR"""'}
u = "RF'''"

Modules

collections

functools

re

sys