Log in / create account | Login with OpenID
DocForge
An Open Wiki For Software Developers

Whitespace

From DocForge

Whitespace is the visual emptiness in strings, usually implemented with newline, tab and space characters. While documents are typically printed or written on white paper, leaving white space between characters, computer displays and other electronics may render the background as any color.

Characters [edit]

Character ASCII Decimal Value Escape
Space 32
Tab 9 \t
Newline 10 \n
Carriage Return 13 \r


Source Code [edit]

In free-form programming languages, whitespace characters in source code are ignored by compilers and interpreters, serving only to help organize source code and separate tokens. For example, tab or space characters can show a hierarchical relationship between lines by indenting them by different amounts, such as nested loops. Therefore proper use of whitespace is an important part of good coding standards.

In non-free-form programming languages, such as Python, whitespace characters are used to determine blocks of code by the compiler. The code of a function or a loop is indented further with whitespace and not delimited with keywords or other characters.