On 27/05/18 01:19, Mike McClain wrote:
>     In their discussion of 'List replication operator'
> Steven D'Aprano and Ben Finney used these '_' and '__'.
> Steve said, "[[] for _ in range(5)]".
> Ben said, "[ [] for __ in range(5) ]".
> 
>     These aren't listed separately in the index, where might I find
> written discussion of these?

There's nothing special about _, it's just a possible name of a
variable, albeit a very short and entirely uninformative one. Normally,
it's not something you'd actually want to name a variable, of course.

As such, _ has become an idiomatic name for dummy variables, i.e.
something you use when syntax requires you to give a variable name, but
you don't actually want one (probably because you're throwing the
variable away). This mostly happens in generator expressions/list
comprehensions.

-- Thomas
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to