Underscore alone is a special variable name and I’m pretty sure anything assigned to it goes straight to garbage collection. Whereas _myvariable is typically used to indicate a “private” class variable or method (Python doesn’t have private so it’s just a convention).
You can use anything that doesn’t start with a digit or punctuation as a variable name (underscore beginning also allowed) unless it’s a keyword.
_ (sic) as a variable name is often used when a function returns multiple outputs but you only want one
_
can also be used in the python interactive terminal to mean ‘last return value’Ie:
> 'string' 'string' > a = _ > print(a) string
Underscore alone is a special variable name and I’m pretty sure anything assigned to it goes straight to garbage collection. Whereas
_myvariable
is typically used to indicate a “private” class variable or method (Python doesn’t have private so it’s just a convention).