this post was submitted on 08 Jun 2025
515 points (97.2% liked)

Programmer Humor

36825 readers
12 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 9 points 3 weeks ago (11 children)

In Python you can use this as a variable name

[–] [email protected] 4 points 3 weeks ago (3 children)

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.

[–] [email protected] 3 points 3 weeks ago* (last edited 3 weeks ago) (2 children)

_ (sic) as a variable name is often used when a function returns multiple outputs but you only want one

 def my_function:
      return 1, 2, 3

 _, two, _ = my_function()
[–] [email protected] 1 points 2 weeks ago

_ can also be used in the python interactive terminal to mean 'last return value'

Ie:

> 'string'
'string'
> a = _
> print(a)
string
load more comments (1 replies)
load more comments (1 replies)
load more comments (8 replies)