Skip to content

Instantly share code, notes, and snippets.

View acrymble's full-sized avatar

Adam Crymble acrymble

  • London
View GitHub Profile
@acrymble
acrymble / python-slice-variables.py
Created June 30, 2011 12:47
Python Slice variables
startLoc = 2
endLoc = 8
message9b = message9[startLoc: endLoc]
print message9b
-> llo Wo
@acrymble
acrymble / python-argument.py
Created June 30, 2011 12:48
Python Argument
print len(message7)
@acrymble
acrymble / python-escape.py
Created June 30, 2011 12:51
Python Escape
print '\"'
-> "
@acrymble
acrymble / python-escape-sentence.py
Created June 30, 2011 12:52
Python Escape sentence
print 'The program printed \"hello world\"'
-> The program printed "hello world"
@acrymble
acrymble / python-escape-tab-newline.py
Created June 30, 2011 12:53
Python Escape tab and newline
print 'hello\thello\thello\nworld'
->hello hello hello
world
@acrymble
acrymble / obo.py
Created June 30, 2011 12:56
obo.py
# obo.py
def stripTags(pageContents):
startLoc = pageContents.find("<hr/><h2>")
pageContents = pageContents[startLoc:]
return pageContents
@acrymble
acrymble / trial-content.py
Created June 30, 2011 12:57
trial-content.py
# trial-content.py
import urllib2, obo
url = 'http://www.oldbaileyonline.org/print.jsp?div=t17800628-33'
response = urllib2.urlopen(url)
HTML = response.read()
print obo.stripTags(HTML)
@acrymble
acrymble / python-for-loop.py
Created June 30, 2011 13:04
Python For Loop
for char in pageContents:
# do something with char
@acrymble
acrymble / python-if.py
Created June 30, 2011 13:05
Python If Statement
if char == '<':
# do something
@acrymble
acrymble / python-if-else.py
Created June 30, 2011 13:06
Python If / Else
if char == '<':
# do something
else:
# do something different