The symbol underscore ( _ ), also called underline, low line or low dash, is a character that originally appeared on the typewriter and was primarily used to underline words. To produce an underlined word, the word was typed, the typewriter carriage was moved back to the beginning of the word, and the word was overstrike with the underscore character.
This character is sometimes used to create visual spacing within a sequence of characters, where a whitespace character is not permitted (e.g., in computer , , and in Internet URLs). Some computer applications will automatically underline text surrounded by underscores: _underlined_ will render underlined. It is often used in plain text-only media (IRC, instant messaging, classical email) for this purpose. When the underscore is used for emphasis in this fashion, it is usually interpreted as indicating that the enclosed text is underlined (as opposed to being italicized or bold, which is indicated by /slashes/ or *asterisks*, respectively).
The underscore is not the same character as the dash character, although one convention for text is to use an underscore when an em-dash or en-dash is desired, or when other non-standard characters such as bullets would be appropriate. A series of underscores (like __________ ) may be used to create a blank to be filled in on a form, although the resulting blank may have tiny gaps between each individual underscore. It is also sometimes used to create a horizontal line; other symbols with similar , such as hyphens and dashes, are also used for this purpose.
A similar Unicode character is , which is an underscore with two horizontal lines instead of one.
Underscore predates the existence of lower-case letters in many systems, so often it had to be used to make multi-word identifiers, as CamelCase (see below) was not available.
An underscore as the first character in an Identifier is often used to indicate internal implementation that is not considered part of the API and should not be called by code outside that implementation. Python uses this for private member variables of classes, this is common in other languages such as C++ even though those provide keywords to indicate that members are private. It is extensively used to hide variables and functions used for implementations in . In fact the use of single underscore for this became so common that C compilers had to standardize on a double leading underscore (for instance __DATE__) for actual built-in variables to avoid conflicts with the ones in header files. Python uses double underscore to "mangle" a private id to make it much harder to refer to it, and "PHP reserves all function names starting with __ as magical."
A variable named with just an underscore often has special meaning. $_ or _ is the previous command or result in many interactive shells, such as those of Python, Ruby, and Perl. In Perl, @_ is a special array variable that holds the arguments to a function.