What is the meaning of _
after for
in this code?
if tbh.bag:
n = 0
for _ in tbh.bag.atom_set():
n += 1
There are 5 cases for using the underscore in Python.
For storing the value of last expression in interpreter.
For ignoring the specific values. (so-called “I don’t care”)
To give special meanings and functions to name of vartiables or functions.
To use as ‘Internationalization(i18n)’ or ‘Localization(l10n)’ functions.
To separate the digits of number literal value.
Here is a nice article with examples by mingrammer.