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

Class Number

Lib/test/test_descr.py:276–289  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274 'floordiv', 'divmod', 'mod'])
275
276 class Number(complex):
277 __slots__ = ['prec']
278 def __new__(cls, *args, **kwds):
279 result = complex.__new__(cls, *args)
280 result.prec = kwds.get('prec', 12)
281 return result
282 def __repr__(self):
283 prec = self.prec
284 if self.imag == 0.0:
285 return "%.*g" % (prec, self.real)
286 if self.real == 0.0:
287 return "%.*gj" % (prec, self.imag)
288 return "(%.*g+%.*gj)" % (prec, self.real, prec, self.imag)
289 __str__ = __repr__
290
291 a = Number(3.14, prec=6)
292 self.assertEqual(repr(a), "3.14")

Callers 1

test_complexesMethod · 0.70

Calls

no outgoing calls

Tested by 1

test_complexesMethod · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…