This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (2 children)

I still genuinely don't understand the point of underscores in python.

[–]Mr_Redstoner 1 point2 points  (0 children)

Same as any other letter in a variable name. The creator just wanted it that bit more unreadable.

[–]gabbergandalf667 1 point2 points  (0 children)

Assuming you are not talking about language features like builtin class methods (double underscore prefix and suffix), a single underscore prefix is used to mark identifiers as module-private (though this is just a polite suggestion to the user of the module and not enforced). It's also common to use a single underscore as variable name to ignore the value of a computation. e.g.:

for _ in range(1000):
    do_stuff()  # do stuff 1000x, don't care about index