MCPcopy Index your code
hub / github.com/python/cpython / escape_char

Method escape_char

Lib/_ast_unparse.py:538–546  ·  view source on GitHub ↗
(c)

Source from the content-addressed store, hash-verified

536 Returns the tuple (string literal to write, possible quote types).
537 """
538 def escape_char(c):
539 # \n and \t are non-printable, but we only escape them if
540 # escape_special_whitespace is True
541 if not escape_special_whitespace and c in "\n\t":
542 return c
543 # Always escape backslashes and other non-printable characters
544 if c == "\\" or not c.isprintable():
545 return c.encode("unicode_escape").decode("ascii")
546 return c
547
548 escaped_string = "".join(map(escape_char, string))
549 possible_quotes = quote_types

Callers

nothing calls this directly

Calls 3

isprintableMethod · 0.80
decodeMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected