Rocking the blogosphere

Python cheatsheet

Under construction

#
# Data types
#

tuple = (1, 2, 3)
array = [1, 2, 3]
hash = { "key1": "value1", "key2", "value2" }

#
# List comprehension
#

[2 * x for x in [1, 2, 3]]

#
# I/O
#

print("array = %s; hash = %s" % (array, hash))

#
# Libraries
#

import sys; dir(sys)
from time import time, sleep
import urllib2                               # Web stuff

No comments yet. Be the first.

Leave a reply