|
⇤ ← Revision 1 as of 2009-11-08 13:27:27
Size: 533
Comment:
|
Size: 629
Comment: Added syntax colouring.
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 5: | Line 5: |
| {{{ | {{{#!python numbers=disable |
| Line 12: | Line 12: |
| {{{ | {{{#!python numbers=disable |
| Line 19: | Line 19: |
| {{{ | {{{#!python numbers=disable |
| Line 29: | Line 29: |
| {{{ | {{{#!python numbers=disable |
Here are some samples to help get a better idea of Python's syntax:
String formatting
name = 'Monty'
print 'Hello, %s' % name
Defining a function
def add_one(x):
return x + 1
Defining a class with two methods
class Talker(object):
def greet(self, name):
print 'Hello, %s!' % name
def farewell(self, name):
print 'Farewell, %s!' % name
Defining a list
dynamic_languages = ['Python', 'Ruby', 'Groovy']
dynamic_languages.append('Lisp')
