Question:
In Python, the variable name_
(underscore) is often used for throwaway variables (variables that will never be used, hence do not need a proper name).With the walrus operator,
:=
, I see the need for a variable that is rather short lived (used in say only one line of code). I wonder if the use of _
is reasonable to use also in this case, or if it might be confusing for someone reading the code?Example:
dummy
could in my opinion be replaced with _
:Answer:
You are using the variabledummy
, to filter the series. Therefore, don’t replace it with _
.If you have better answer, please add a comment about this, thank you!