.. _used-before-assignment:

used-before-assignment / E0601
==============================

**Message emitted:**

Using variable %r before assignment

**Description:**

*Emitted when a local variable is accessed before its assignment took place. Assignments in try blocks are assumed not to have occurred when evaluating associated except/finally blocks. Assignments in except blocks are assumed not to have occurred when evaluating statements outside the block, except when the associated try block contains a return statement.*

**Problematic code:**

.. literalinclude:: /data/messages/u/used-before-assignment/bad.py
   :language: python

**Correct code:**

.. literalinclude:: /data/messages/u/used-before-assignment/good.py
   :language: python



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