|Paradigm||Multiple: object-oriented, imperative, functional|
|Designed by||Guido van Rossum|
|Developer||Python Software Foundation|
|Influenced by||ABC, ALGOL 68, C, Haskell, Icon, Lisp, Modula-3, Perl, Java|
A new version of Python has come out, Version 3.1.2. In version 3.1.2, the syntax is different from 2.5.2. So perhaps a new page or section should be created with the new syntax and information.
Python is a very high-level dynamic object-oriented programming language that can be used for many kinds of software development. It has been used to creating a few bot systems on dAmn.
<python>string = "This is a string in Python!"</python>
Different types of quote marks work with Python:
<python># This will work. string = "Python string's rock!"
- This will too.
string = 'Python strings rock!'
- Escaping quote marks normally
string = 'Python string\'s rock!'</python>
To print a string, issue the <python-inline>print</python-inline> statement: <python>print "Hello, world!"</python>
You can also simply save it in variables and then handle variables like in most other languages. <python>string = "This is a Python string!" print string</python>
Writing multi-line strings in Python is done using triple quotes: <python-inline>"""</python-inline> or <python-inline></python-inline>, like so: <python>print """ This is an example of a multi-line string in python. """</python>
Strings can also be concatenated, and the easiest method of achieving this is using the <python-inline>+</python-inline> operator: <python>string = 'this is' + ' ' + 'a string'</python>
Strings can also be repeated with the <python-inline>*</python-inline> operator: <python>print "test" * 5
- outputs: testtesttesttesttest
Strings also support indexes: <python>string = 'test0' print string
- outputs: t</python>
We printed the 4th indexed character in the string, which is "
t" in this case.
Lists (known as non-associative arrays in other languages) are fairly easy, below is a simple example of how to use them:
<python>l = ['bot', 'dom'] print l
- outputs: ['bot', 'dom']
- outputs: bot
- outputs: dom
You can also merge several lists using the <python-inline>+</python-inline> operator <python> print ['bot','dom'] + ['foo','bar']
- outputs: ['bot','dom','foo','bar']</python>