sympy/sympy — pull request #1470 by asmeurer (2012-08-07 22:22:36+00:00)
Title: Autorat

This fixes http://code.google.com/p/sympy/issues/detail?id=3182. There is now a `-i` option to isympy, which allows automatic wrapping of integer literals with Integer. The result is that things like `1/2` will be converted to `Rational(1, 2)` automatically. For example:

```py
$./bin/isympy -i
IPython console for SymPy 0.7.1-git (Python 2.7.3-64-bit) (ground types: python)

These commands were executed:
>>> from __future__ import division
>>> from sympy import *
>>> x, y, z, t = symbols('x y z t')
>>> k, m, n = symbols('k m n', integer=True)
>>> f, g, h = symbols('f g h', cls=Function)

Documentation can be found at http://www.sympy.org

In [1]: 1/2
Out[1]: 1/2

In [2]: x**(1/2)
Out[2]:
___
╲╱ x
```

To get a Python int, you can wrap the literal with `int()`. This works by preprocessing the code with tokenize and wrapping all non-float number literals with Integer. There was some discussion about the best way to make IPython do this (see the commit message and the discussions linked to there).

Still todo: tests.