Does underscore has any special built-in meaningin Python ?

alex23 wuwei23 at
Wed Jul 29 20:24:03 EDT 2009

On Jul 30, 3:59 am, dandi kain <dandi.k... at> wrote:
> What is the functionality of __ or _ , leading or trailing an object ,
> class ot function ? Is it just a naming convention to note special
> functions and objects , or it really mean someting to Python ?

I think everyone else has covered what you need to know, but there's
still one remaining pseudo-convention you might see in Python code,
and that's using _ as a label to indicate that you don't care about
the value it holds.

Overly simplistic example:

data_set = [('gold','junk'),('gold','junk'),...]

for keep, _ in data_set:

It's a convenient way of not having to come up with a label for
something you're not going to use, although arguably you get the same
effect with names like 'dummy', 'ignore' etc. Not everyone agrees with
this usage but you _will_ see it in use in other people's code, so it
helps to have a heads up.

More information about the Python-list mailing list