updated: 7th of April 2019
published: 2nd of October 2017
# Single line comment
# Multiple
# line
# comment
"""Single line docstring"""
"""
Multiple
line
docstring
"""
stuff = 'stuff'
'Single line string'
'''
Multiple
line
string
'''
42
True
# or
False
['stuff', 'things']
('stuff', 'things')
{'stuff_key': 'stuff_value', 'things_key': 'things_value'}
# Iterate list or tuple
for thing in things:
print(thing)
# Iterate dictionary
for key, value in stuff.items():
print(key, value)
thing = True
while thing is True:
print(thing)
thing = False
if 1 > 42:
print('One')
elif 42 < 1:
print('The answer')
else:
print('Maths is fun')
def stuff():
'''Get stuff'''
stuff = ['stuff', 'more stuff', 'other stuff']
return stuff
class StuffAndThings(object):
"""Stuff and things"""
def __init__(self, stuff, things):
self.stuff = stuff
self.things = things
def get_stuff():
"""Get stuff"""
return self.stuff
def get_things():
"""Get things"""
return self.things
import os