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

Method _write_constant

Lib/_ast_unparse.py:693–703  ·  view source on GitHub ↗
(self, value)

Source from the content-addressed store, hash-verified

691 self._write_str_avoiding_backslashes(node.value, quote_types=_MULTI_QUOTES)
692
693 def _write_constant(self, value):
694 if isinstance(value, (float, complex)):
695 # Substitute overflowing decimal literal for AST infinities,
696 # and inf - inf for NaNs.
697 self.write(
698 repr(value)
699 .replace("inf", _INFSTR)
700 .replace("nan", f"({_INFSTR}-{_INFSTR})")
701 )
702 else:
703 self.write(repr(value))
704
705 def visit_Constant(self, node):
706 value = node.value

Callers 2

visit_ConstantMethod · 0.95
visit_MatchSingletonMethod · 0.95

Calls 2

writeMethod · 0.95
replaceMethod · 0.45

Tested by

no test coverage detected