Python is a general purpose, high level, Interpreted Programming Language. The Python philosophy emphasises readability and simplicity. To this day, Python enforces the use of indentation to denote code blocks, and features dynamic typing along with automatic memory management.
Python's use of indentation as a code block delimiter makes it unique among popular programming languages, and enforces a single consistent coding style, unlike C and Java. This is one of the more popular features of the language within the Python community, though it is sometimes confusing for those new to the language who are conversant with other programming languages.
Python is frequently used as a scripting language, but its large array of built-in libraries means that it is also used more frequently than other high-level languages for general-purpose programming.
Other interesting stuffEdit
- Python syntax (Wikipedia) Python Syntax, including functional-programming in Python
Including Sample Code in a WikiEdit
To put code in one of these boxes, you have to indent each line of wiki-text by one space:
def function(): print "hello"
Fortunately, cutting and pasting out of the box results in properly formatted Python code. To quickly format your code for cut-and-paste into the wiki on a Linux computer, you can use the sed command.
$ sed -e 's/^/ /' < file.py
This command adds a single space to the beginning of each line of your file. Since empty lines cause new boxes to be created, you'll probably want to adjust the output code to taste.
Easier Editing ExternallyEdit
In vim, you can add a line to your vimrc that will add one space to any block of text that you highlight, if you press backslash-p.
:map <leader>p :!sed -e 's/^/ /'<CR>
Tab completion Edit
Tab completion can be implemented in the python interpreter with the following in your
import readline, rlcompleter readline.parse_and_bind("tab: complete")
Then save the following line in your
.bashrc and run it in any open terminals it needs to take effect on: