catacomb/__init__.py: Rearrange the imports.
[catacomb-python] / catacomb / __init__.py
index f6a5491..53d7cea 100644 (file)
 
 from __future__ import with_statement
 
-import _base
-import types as _types
 from binascii import hexlify as _hexify, unhexlify as _unhexify
 from contextlib import contextmanager as _ctxmgr
-from sys import argv as _argv
 from struct import pack as _pack
+import sys as _sys
+import types as _types
+
+###--------------------------------------------------------------------------
+### Import the main C extension module.
+
+import _base
 
 ###--------------------------------------------------------------------------
 ### Basic stuff.
 
-## For the benefit of the default keyreporter, we need the program na,e.
-_base._ego(_argv[0])
+## For the benefit of the default keyreporter, we need the program name.
+_base._ego(_sys.argv[0])
 
 ## How to fix a name back into the right identifier.  Alas, the rules are not
 ## consistent.
@@ -313,12 +317,14 @@ class BaseRat (object):
     n, d = _split_rat(you)
     return type(me)(me._n*n, me._d*d)
   __rmul__ = __mul__
-  def __div__(me, you):
+  def __truediv__(me, you):
     n, d = _split_rat(you)
     return type(me)(me._n*d, me._d*n)
-  def __rdiv__(me, you):
+  def __rtruediv__(me, you):
     n, d = _split_rat(you)
     return type(me)(me._d*n, me._n*d)
+  __div__ = __truediv__
+  __rdiv__ = __rtruediv__
   def __cmp__(me, you):
     n, d = _split_rat(you)
     return cmp(me._n*d, n*me._d)
@@ -341,8 +347,10 @@ class _tmp:
   def mont(x): return MPMont(x)
   def barrett(x): return MPBarrett(x)
   def reduce(x): return MPReduce(x)
-  def __div__(me, you): return IntRat(me, you)
-  def __rdiv__(me, you): return IntRat(you, me)
+  def __truediv__(me, you): return IntRat(me, you)
+  def __rtruediv__(me, you): return IntRat(you, me)
+  __div__ = __truediv__
+  __rdiv__ = __rtruediv__
   _repr_pretty_ = _pp_str
 _augment(MP, _tmp)
 
@@ -353,8 +361,10 @@ class _tmp:
   def halftrace(x, y): return x.reduce().halftrace(y)
   def modsqrt(x, y): return x.reduce().sqrt(y)
   def quadsolve(x, y): return x.reduce().quadsolve(y)
-  def __div__(me, you): return GFRat(me, you)
-  def __rdiv__(me, you): return GFRat(you, me)
+  def __truediv__(me, you): return GFRat(me, you)
+  def __rtruediv__(me, you): return GFRat(you, me)
+  __div__ = __truediv__
+  __rdiv__ = __rtruediv__
   _repr_pretty_ = _pp_str
 _augment(GF, _tmp)