Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Duplicate importing of functions

from mycalc import add
print(add(2, 3))  # 5

from mymath import add
print(add(2, 3))  # 6

from mycalc import add
print(add(2, 3))  # 5

The second declaration silently overrides the first declaration.

pylint can find such problems, along with a bunch of others.

pylint --disable=C  duplicate_add_from_module.py
************* Module duplicate_add_from_module
duplicate_add_from_module.py:4:0: W0404: Reimport 'add' (imported line 1) (reimported)
duplicate_add_from_module.py:7:0: W0404: Reimport 'add' (imported line 1) (reimported)

------------------------------------------------------------------
Your code has been rated at 6.67/10 (previous run: 5.00/10, +1.67)