print "Hello World"
print "Hello", "World"
print "Hello"
print "World"
print "Hello",
print "World"
print("Hello World")
print("Hello", "World")
2 / 3
2 / 3.0
2.0 / 3.0
2.0 / 3
"Hello World"
u"Hello World"
"Hello World".decode("ascii")
u"Hello World".decode("ascii")
"Hello World".encode("ascii")
u"Hello World".encode("ascii")
print "Hello\nWorld"
"Hello\nWorld"
print r"Hello\nWorld"
r"Hello\nWorld"
print repr("Hello \U0001F40D")
print "Hello \U0001F40D"
print repr(u"Hello \U0001F40D")
print u"Hello \U0001F40D"
print repr(u"Hello \U0001F40D".encode('utf8'))
print u"Hello \U0001F40D".encode('utf8')
print repr("Hello \xF0\x9F\x90\x8D")
print "Hello \xF0\x9F\x90\x8D"
print repr("Hello \xF0\x9F\x90\x8D".decode('utf8'))
print "Hello \xF0\x9F\x90\x8D".decode('utf8')
for c in "Hello World":
print c
for c in "Hello World":
print ord(c)
range(2)
xrange(2)
map(str, [1, 2, 3])
from itertools import imap
imap(str, [1, 2, 3])
d = {'a': 1, 'b': 2, 'c': 3}
d.items()
d.iteritems()
def high_memory(runs):
from time import time
print "Computing %d iterations" % runs
start = time()
for i in range(runs):
pass
print "Long running computation finished 1 after %f sec" % (time() - start)
from multiprocessing import Process
p = Process(target=high_memory, args=(int(5e8),))
p.start()
print "Process", p.name, "started"
p.join()
def low_memory(runs):
from time import time
print "Computing %d iterations" % runs
start = time()
for i in xrange(runs):
pass
print "Long running computation finished 2 after %f sec" % (time() - start)
from multiprocessing import Process
p = Process(target=low_memory, args=(int(5e8),))
p.start()
print "Process", p.name, "started"
p.join()
try:
raise IOError('Foo')
except IOError as e:
raise
try:
raise IOError('Foo')
except IOError as e:
raise RuntimeError('Bar')