How to make an integer larger than any other integer?
<p>Note: while the accepted answer achieves the result I wanted, and @ecatmur answer provides a more comprehensive option, I feel it's very important to emphasize that my use case is a bad idea in the first place. This is explained very well in <a href="http://stackoverflow.com/a/39856605/336527">@Jason Orendorff answer below</a>.</p>

<p>Note: this question is not a duplicate of <a href="http://stackoverflow.com/questions/13795758/what-is-sys-maxint-in-python-3">the question about <code>sys.maxint</code></a>. It has nothing to do with <code>sys.maxint</code>; even in python 2 where <code>sys.maxint</code> is available, it does NOT represent largest integer (see the accepted answer).</p>

<p>I need to create an integer that's larger than any other integer, meaning an <code>int</code> object which returns <code>True</code> when compared to any other <code>int</code> object using <code>&gt;</code>. Use case: library function expects an integer, and the only easy way to force a certain behavior is to pass a very large integer.</p>

<p>In python 2, I can use <code>sys.maxint</code> (edit: I was wrong). In python 3, <code>math.inf</code> is the closest equivalent, but I can't convert it to <code>int</code>.</p>

<blockquote>
  <p><strong>In Python 3.5, you can do:</strong></p>
  
  <p><code>import math
  test = math.inf</code></p>
  
  <p>And then:</p>
  
  <p><code>test &gt; 1
  test &gt; 10000
  test &gt; x</code></p>
  
  <p>Will always be true. Unless of course, as pointed out, x is also infinity or "nan" ("not a number").</p>
</blockquote>

<p><a href="https://stackoverflow.com/questions/7781260/how-can-i-represent-an-infinite-number-in-python">How can I represent an infinite number in Python?</a></p>

<p>Answered by @WilHall</p>

python python-3.x