chiark / gitweb /
catacomb/__init__.py: Print groups properly.
[catacomb-python] / catacomb / __init__.py
index f9436802e5a360da1a7ebcf973596efeb2abaa0b..bc050be8a40ba99009511e0661fedcdd01b4195b 100644 (file)
@@ -384,6 +384,16 @@ class _tmp:
   def __str__(me):
     if not me: return 'inf'
     return '(%s, %s)' % (me.x, me.y)
+  def _repr_pretty_(me, pp, cyclep):
+    if cyclep:
+      pp.text('...')
+    elif not me:
+      pp.text('inf')
+    else:
+      ind = _pp_bgroup(pp, '(')
+      pp.pretty(me.x); pp.text(','); pp.breakable()
+      pp.pretty(me.y)
+      pp.end_group(ind, ')')
 _augment(ECPtCurve, _tmp)
 
 ###--------------------------------------------------------------------------
@@ -564,6 +574,11 @@ _augment(BinDHInfo, _tmp)
 class _tmp:
   def __repr__(me):
     return '%s(%r)' % (type(me).__name__, me.info)
+  def _repr_pretty_(me, pp, cyclep):
+    ind = _pp_bgroup_tyname(pp, me)
+    if cyclep: pp.text('...')
+    else: pp.pretty(me.info)
+    pp.end_group(ind, ')')
 _augment(Group, _tmp)
 
 class _tmp: