In Python, you can do:

test = float("inf")

In Python 3.5, you can do:

import math
test = math.inf

And then:

test > 1
test > 10000
test > x

Will always be true. Unless of course, as pointed out, x is also infinity or "nan" ("not a number").

Additionally (Python 2.x ONLY), in a comparison to Ellipsis, float(inf) is lesser, e.g:

float('inf') < Ellipsis

would return true.

Answer from WilHall on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-infinity
Python infinity (inf) - GeeksforGeeks
Infinity represents a value that is greater than every finite number or smaller than every finite negative number. Python does not provide an integer type for infinity, but it supports positive and negative infinity through floating-point values ...
Published: 1 week ago
🌐
CodeGym
codegym.cc › java blog › learning python › infinity in python: mastering the infinite
Infinity in Python: Mastering the Infinite
August 13, 2024 - By initializing your comparison ... and elegant. Python provides a straightforward way to represent infinity using the float() function....
🌐
Python.org
discuss.python.org › ideas
Integer infinity - Ideas - Discussions on Python.org
December 11, 2023 - You could accomplish this by annotating retries: int | float and passing retries=float("inf") or retries=math.inf, but it would be nice if you could just pass int("inf") and not need to change the type annotation.
🌐
W3Schools
w3schools.com › python › ref_math_inf.asp
Python math.inf Constant
The math.inf constant returns a floating-point positive infinity.
🌐
FavTutor
favtutor.com › blogs › infinity-python
Infinity in Python (float('inf'), math.inf) | FavTutor
July 21, 2026 - Python offers three ways to get infinity: float("inf"), math.inf, and NumPy's np.inf.
Find elsewhere
🌐
Medium
medium.com › @c.fedesna › float-inf-in-python-c942e28340da
Float(‘inf’) in Python
November 21, 2023 - float(‘inf’) in Python is used to represent infinity. Yes, a number to represent infinity… which I keep wondering where it will really be…
🌐
Codecademy
codecademy.com › docs › python › math module › math.isinf()
Python | Math Module | math.isinf() | Codecademy
September 4, 2024 - The math.isinf() function in Python checks whether a given value is infinite. It returns True if the value is positive or negative infinity, and False otherwise.
🌐
Medium
allwin-raju.medium.com › infinity-in-python-b1d8e03803aa
Infinity in Python. In Python, you can represent infinity… | by Allwin Raju | Medium
February 5, 2025 - Infinity in Python In Python, you can represent infinity using float('inf'). It can be used in mathematical operations, comparisons, and algorithms that require an infinitely large value. Read for …
🌐
Reddit
reddit.com › r › Python
r/Python
January 25, 2008 - New Python releases are out, 3.10.x reaches EOL, (and 3.15.0 is scheduled for today)!
🌐
Note.nkmk.me
note.nkmk.me › home › python
Infinity (inf) in Python | note.nkmk.me
August 11, 2023 - You can create inf by specifying the string 'inf' or 'infinity' to float().
🌐
W3Schools
w3schools.com › python
Python Tutorial
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
🌐
Online Python
online-python.com
Online Python - IDE, Editor, Compiler, Interpreter
Python, which was initially developed by Guido van Rossum and made available to the public in 1991, is currently one of the most widely used general-purpose programming languages. Python's source code is freely available to the public, and its usage and distribution are unrestricted, including for commercial purposes.
🌐
iO Flood
ioflood.com › blog › python-infinity
Python Infinity: Syntax, Uses, and Examples
np.where Python Function | Quick Tips for Numpy · Python Sleep Methods | How to Make Code Pause or Wait · Pip Install Requirements.txt | Python Package Manager · Python Programming Guide · Wordpress Website Speedup Guide · Kubernetes and Docker Guide · Python Syntax Cheat Sheet ·
🌐
Codecademy
codecademy.com › catalog › language › python
Best Python Courses + Tutorials | Codecademy
August 22, 2026 - Python is a general-purpose, versatile, and powerful programming language. It's a great first language because Python code is concise and easy to read. Whatever you want to do, python can do it.
🌐
Replit
replit.com › home › discover › how to write infinity in python
How to write infinity in Python | Replit
April 14, 2026 - Learn how to represent infinity in Python. Discover different methods, real-world applications, and tips for debugging common errors.
🌐
AWS
aws.amazon.com › what is cloud computing? › cloud computing concepts hub › developer tools › what is python?
What is Python? - Python Language Explained - AWS
1 week ago - Find out more about the easy-to-learn programming language python, what the benefits of python are, and discover resources for using python.
🌐
Google
developers.google.com › google for education › python
Google's Python Class | Python Education | Google for Developers
Welcome to Google's Python Class -- this is a free class for people with a little bit of programming experience who want to learn Python. The class includes written materials, lecture videos, and lots of code exercises to practice Python coding.
🌐
DEV Community
dev.to › hrishikesh1990 › how-to-represent-an-infinite-number-in-python-2fm2
How to represent an infinite number in Python? - DEV Community
April 18, 2022 - According to this standard, a floating-point number represents an infinity when all the bits in the exponent part are 1, and all the bits in the mantissa part are 0. Additionally, if the sign bit is 0, it is positive infinity, while a 1 in the ...