.. _literal-comparison:

literal-comparison / R0123
==========================

**Message emitted:**

In '%s', use '%s' when comparing constant literals not '%s' ('%s')

**Description:**

*Used when comparing an object to a literal, which is usually what you do not want to do, since you can compare to a different literal than what was expected altogether.*

**Problematic code:**

.. literalinclude:: /data/messages/l/literal-comparison/bad.py
   :language: python

**Correct code:**

.. literalinclude:: /data/messages/l/literal-comparison/good.py
   :language: python


**Related links:**

- `Comparison operations in Python <https://docs.python.org/3/library/stdtypes.html#comparisons>`_

Created by the `basic <https://github.com/PyCQA/pylint/blob/main/pylint/checkers/base/comparison_checker.py>`__ checker.