Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ The code below demonstrates the dangers of variables whose names include type no
Best practice
-------------

Remove type notation
Use type hint
....................

Although the modifed code below does not fix the underlying problem of attempting to divide a number by a string, the code is generally less misleading, because there is no misleading description in the variable name ``n`` that ``n`` is a number.

.. code:: python

n = "Hello, World!"
n: str = "Hello, World!"

# still a problem, but less misleading now
4 / n
Expand Down