Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.

    ****************************************************************
    Personal firewall software may warn about the connection IDLE
    makes to its subprocess using this computer's internal loopback
    interface.  This connection is not visible on any external
    interface and no data is sent to or received from the Internet.
    ****************************************************************
    
IDLE 1.2      
>>> 
>>> 'Spam!' + 'NI'
'Spam!NI'
>>> 
>>> 2 ** 40
1099511627776L
>>> 
>>> import sys
>>> sys.path
['C:\\Python25\\Lib\\idlelib', 'C:\\WINDOWS\\system32\\python25.zip', 'C:\\Python25\\DLLs', 'C:\\Python25\\lib', 'C:\\Python25\\lib\\plat-win', 'C:\\Python25\\lib\\lib-tk', 'C:\\Python25', 'C:\\Python25\\lib\\site-packages', 'C:\\Python25\\lib\\site-packages\\PIL', 'C:\\Python25\\lib\\site-packages\\wx-2.7.2-msw-ansi']
>>> 
>>> ================================ RESTART ================================
>>> 
1267650600228229401496703205376
win32
Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!
>>> ================================ RESTART ================================
>>> 
10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376
win32
Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!
>>> ================================ RESTART ================================
>>> 
10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376
win32

Traceback (most recent call last):
  File "C:\Python25\sgapr08.py", line 5, in <module>
    x = 'Spam!' + Z
NameError: name 'Z' is not defined
>>> 
[DEBUG ON]
>>> 
[DEBUG OFF]
>>> reload(sgapr08)

Traceback (most recent call last):
  File "<pyshell#8>", line 1, in <module>
    reload(sgapr08)
NameError: name 'sgapr08' is not defined
>>> 
>>> import sgapr08
10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376
win32
Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!

>>> reload(sgapr08)
10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376
win32
Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!

<module 'sgapr08' from 'C:\Python25\sgapr08.pyc'>
>>> 
>>> 
>>> S = 'Spam'
>>> len(S)
4
>>> S + 'NI'
'SpamNI'
>>> 
>>> X = S + 'NI'
>>> X
'SpamNI'
>>> 
>>> S
'Spam'
>>> S * 80
'SpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpam'
>>> 
>>> print '-' * 80
--------------------------------------------------------------------------------
>>> 
>>> S
'Spam'
>>> 
>>> S[0]
'S'
>>> S[1]
'p'
>>> S[-1]
'm'
>>> S[-2]
'a'
>>> 
>>> S
'Spam'
>>> S[len(S)-1]
'm'
>>> S[-1]
'm'
>>> 
>>> S
'Spam'
>>> S[1:3]
'pa'
>>> S[1:]
'pam'
>>> S[:]
'Spam'
>>> S[:3]
'Spa'
>>> 
>>> S[:-1]
'Spa'
>>> 
>>> S
'Spam'
>>> 
>>> S
'Spam'
\
>>> S = S[:-1]
>>> S
'Spa'
>>> S
'Spa'
>>> 
>>> S[0]
'S'
>>> S[0] = 'x'

Traceback (most recent call last):
  File "<pyshell#53>", line 1, in <module>
    S[0] = 'x'
TypeError: 'str' object does not support item assignment
>>> 
>>> 
>>> S
'Spa'
>>> 
>>> S.upper()
'SPA'
>>> 
>>> S.find('pa')
1
>>> 
>>> S.replace('pa', 'XYZ')
'SXYZ'
>>> 
>>> S
'Spa'
>>> 
>>> 
>>> line = '111,222,333,444'
>>> 
>>> cols = line.split(',')
>>> cols
['111', '222', '333', '444']
>>> 
>>> line = '111,222,333,444\n'
>>> 
>>> line[:-1]
'111,222,333,444'
>>> 
>>> line.rstrip()
'111,222,333,444'
>>> 
>>> dir(line)
['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__str__', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
>>> 
>>> help(line.startswith)
Help on built-in function startswith:

startswith(...)
    S.startswith(prefix[, start[, end]]) -> bool
    
    Return True if S starts with the specified prefix, False otherwise.
    With optional start, test S beginning at that position.
    With optional end, stop comparing S at that position.
    prefix can also be a tuple of strings to try.

>>> import os
>>> dir(os)
['F_OK', 'O_APPEND', 'O_BINARY', 'O_CREAT', 'O_EXCL', 'O_NOINHERIT', 'O_RANDOM', 'O_RDONLY', 'O_RDWR', 'O_SEQUENTIAL', 'O_SHORT_LIVED', 'O_TEMPORARY', 'O_TEXT', 'O_TRUNC', 'O_WRONLY', 'P_DETACH', 'P_NOWAIT', 'P_NOWAITO', 'P_OVERLAY', 'P_WAIT', 'R_OK', 'SEEK_CUR', 'SEEK_END', 'SEEK_SET', 'TMP_MAX', 'UserDict', 'W_OK', 'X_OK', '_Environ', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '_copy_reg', '_execvpe', '_exists', '_exit', '_get_exports_list', '_make_stat_result', '_make_statvfs_result', '_pickle_stat_result', '_pickle_statvfs_result', 'abort', 'access', 'altsep', 'chdir', 'chmod', 'close', 'curdir', 'defpath', 'devnull', 'dup', 'dup2', 'environ', 'error', 'execl', 'execle', 'execlp', 'execlpe', 'execv', 'execve', 'execvp', 'execvpe', 'extsep', 'fdopen', 'fstat', 'fsync', 'getcwd', 'getcwdu', 'getenv', 'getpid', 'isatty', 'linesep', 'listdir', 'lseek', 'lstat', 'makedirs', 'mkdir', 'name', 'open', 'pardir', 'path', 'pathsep', 'pipe', 'popen', 'popen2', 'popen3', 'popen4', 'putenv', 'read', 'remove', 'removedirs', 'rename', 'renames', 'rmdir', 'sep', 'spawnl', 'spawnle', 'spawnv', 'spawnve', 'startfile', 'stat', 'stat_float_times', 'stat_result', 'statvfs_result', 'strerror', 'sys', 'system', 'tempnam', 'times', 'tmpfile', 'tmpnam', 'umask', 'unlink', 'unsetenv', 'urandom', 'utime', 'waitpid', 'walk', 'write']
>>> help(os.chdir)
Help on built-in function chdir in module nt:

chdir(...)
    chdir(path)
    
    Change the current working directory to the specified path.

>>> 
>>> 
>>> L = [123, 'spam', 1.23]
>>> 
>>> len(L)
3
>>> L + [1, 2, 3, 4, 5]
[123, 'spam', 1.23, 1, 2, 3, 4, 5]
>>> 
>>> L * 5
[123, 'spam', 1.23, 123, 'spam', 1.23, 123, 'spam', 1.23, 123, 'spam', 1.23, 123, 'spam', 1.23]
>>> 
>>> L
[123, 'spam', 1.23]
>>> 
>>> L[0]
123
>>> L[-1]
1.23
>>> 
>>> L[1:]
['spam', 1.23]
>>> 
>>> dir(L)
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delslice__', '__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__setslice__', '__str__', 'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']
>>> 
>>> L
[123, 'spam', 1.23]
>>> 
>>> L.append('NI!')
>>> L
[123, 'spam', 1.23, 'NI!']
>>> 
>>> L.remove(1.23)
>>> L
[123, 'spam', 'NI!']
>>> 
>>> 
>>> S
'Spa'
>>> 
>>> S = S + 'X'
>>> S
'SpaX'
>>> 
>>> M = [[1, 2, 3],
         [4, 5, 6],
         [7, 8, 9]]
>>> 
>>> M
[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
>>> 
>>> M[1]
[4, 5, 6]
>>> 
>>> M[1][2]
6
>>> 
>>> [row[1] for row in M]
[2, 5, 8]
>>> 
>>> D = {'a': 1, 'b': 2, 'c': 3}
>>> 
>>> D['a']
1
>>> D['b']
2
>>> D
{'a': 1, 'c': 3, 'b': 2}
>>> D['d'] = 4
>>> D
{'a': 1, 'c': 3, 'b': 2, 'd': 4}
>>> 
>>> rec = {}
>>> rec['name'] = 'Bob'
>>> rec['age']  = 40
>>> rec['job']  = 'dev'
>>> 
>>> rec
{'job': 'dev', 'age': 40, 'name': 'Bob'}
>>> 
>>> print rec['name']
Bob
>>> 
>>> rec = {'name': {'first': 'Bob', 'last': 'Smith'},
           'job':  ['dev', 'mgr'],
           'age':  40.5}
>>> 
>>> rec['name']
{'last': 'Smith', 'first': 'Bob'}
>>> rec['name']['last']
'Smith'
>>> 
>>> rec['job'][-1]
'mgr'
>>> rec['job'].append('janitor')
>>> 
>>> rec
{'age': 40.5, 'job': ['dev', 'mgr', 'janitor'], 'name': {'last': 'Smith', 'first': 'Bob'}}
>>> 
>>> rec = 0
>>> 
>>> 
>>> D
{'a': 1, 'c': 3, 'b': 2, 'd': 4}
>>> D.has_key('a')
True
>>> D.has_key('x')
False
>>> D['x']

Traceback (most recent call last):
  File "<pyshell#163>", line 1, in <module>
    D['x']
KeyError: 'x'
>>> 
>>> D
{'a': 1, 'c': 3, 'b': 2, 'd': 4}
>>> dir(D)
['__class__', '__cmp__', '__contains__', '__delattr__', '__delitem__', '__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__str__', 'clear', 'copy', 'fromkeys', 'get', 'has_key', 'items', 'iteritems', 'iterkeys', 'itervalues', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values']
>>> 
>>> 
>>> X = 99
>>> X = 'spam'
>>> X = 1.23
>>> 
>>> 
>>> L = [1, 2, 3]
>>> M = L
>>> 
>>> L == M
True
>>> L is M
True
>>> 
>>> L = [1, 2, 3]
>>> M = [1, 2, 3]
>>> L -- M

Traceback (most recent call last):
  File "<pyshell#182>", line 1, in <module>
    L -- M
TypeError: bad operand type for unary -: 'list'
>>> L == M
True
>>> L is M
False
>>> 
>>> 
>>> X = 42
>>> Y = 42
>>> X == Y
True
>>> X is Y
True
>>> 
>>> import sys
>>> sys.getrefcount(1)
779
>>> 
>>> 
>>> X = 42
>>> Y = 42
>>> 
>>> X = 41
>>> Y
42
>>> X is Y
False
>>> S = 'A\nB\tC'
>>> 
>>> len(S)
5
>>> ord('a')
97
>>> ord('\n')
10
>>> hex(16)
'0x10'
>>> oct(16)
'020'
>>> 
>>> hex(ord('\n'))
'0xa'
>>> 
>>> S = 'A\0B\0C'
>>> 
>>> len(S)
5
>>> S
'A\x00B\x00C'
>>> 
>>> 
>>> msg = """
aaaaaaaaaaaaaaaaaaa
bbbbbbbb'''bbbbb""bbbbbbbbbbbb
ccccccccccccccccc"""
>>> 
>>> msg
'\naaaaaaaaaaaaaaaaaaa\nbbbbbbbb\'\'\'bbbbb""bbbbbbbbbbbb\nccccccccccccccccc'
>>> print msg

aaaaaaaaaaaaaaaaaaa
bbbbbbbb'''bbbbb""bbbbbbbbbbbb
ccccccccccccccccc
>>> 
>>> 
>>> open('C:/new/text')c
SyntaxError: invalid syntax
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> D
{'a': 1, 'c': 3, 'b': 2, 'd': 4}
>>> 
>>> 
>>> D['x']

Traceback (most recent call last):
  File "<pyshell#237>", line 1, in <module>
    D['x']
KeyError: 'x'
>>> 
>>> D.has_key('x')
False
>>> 
>>> 
>>> D
{'a': 1, 'c': 3, 'b': 2, 'd': 4}
>>> 
>>> D.has_key('a')
True
>>> 
>>> if not D.has_key('x'):
	print 'missing'

	
missing
>>> D
{'a': 1, 'c': 3, 'b': 2, 'd': 4}
>>> 
>>> D.get('a', 'missing')
1
>>> 
>>> D.get('x', 'missing')
'missing'
>>> 
>>> D = {'a':1, 'b':2, 'c':3}
>>> 
>>> D
{'a': 1, 'c': 3, 'b': 2}
>>> 
>>> Ks = D.keys()
>>> Ks
['a', 'c', 'b']
>>> 
>>> Ks.sort()
>>> Ks
['a', 'b', 'c']
>>> 
>>> for key in Ks:
	print key, '=>', D[key]

	
a => 1
b => 2
c => 3
>>> 
>>> dir(D)
['__class__', '__cmp__', '__contains__', '__delattr__', '__delitem__', '__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__str__', 'clear', 'copy', 'fromkeys', 'get', 'has_key', 'items', 'iteritems', 'iterkeys', 'itervalues', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values']
>>> 
>>> help(D.keys)
Help on built-in function keys:

keys(...)
    D.keys() -> list of D's keys

>>> D
{'a': 1, 'c': 3, 'b': 2}
>>> 
>>> dir(dict)
['__class__', '__cmp__', '__contains__', '__delattr__', '__delitem__', '__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__str__', 'clear', 'copy', 'fromkeys', 'get', 'has_key', 'items', 'iteritems', 'iterkeys', 'itervalues', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values']
>>> 
>>> 
>>> T = (1, 2, 3, 4)
>>> T[0]
1
>>> T[0] = 9

Traceback (most recent call last):
  File "<pyshell#279>", line 1, in <module>
    T[0] = 9
TypeError: 'tuple' object does not support item assignment
>>> 
>>> 
>>> f = open('data.txt', 'w')
>>> f
<open file 'data.txt', mode 'w' at 0x01414530>
>>> 
>>> f.write('Hello\n')
>>> f.write('world\n')
>>> f.close()
>>> 
>>> f = open('data.txt')
>>> text = f.read()
>>> text
'Hello\nworld\n'
>>> print text
Hello
world

>>> f = open('data.txt')
>>> f.readline()
'Hello\n'
>>> f.readline()
'world\n'
>>> f.readline()
''
>>> f = open('data.txt')
>>> f.read(1)
'H'
>>> f.read(1)
'e'
>>> f.read(1)
'l'
>>> f.read(1)
'l'
>>> 
>>> help(f.seek)
Help on built-in function seek:

seek(...)
    seek(offset[, whence]) -> None.  Move to new file position.
    
    Argument offset is a byte count.  Optional argument whence defaults to
    0 (offset from start of file, offset should be >= 0); other values are 1
    (move relative to current position, positive or negative), and 2 (move
    relative to end of file, usually negative, although many platforms allow
    seeking beyond the end of a file).  If the file is opened in text mode,
    only offsets returned by tell() are legal.  Use of other offsets causes
    undefined behavior.
    Note that not all file objects are seekable.

>>> dir(f)
['__class__', '__delattr__', '__doc__', '__enter__', '__exit__', '__getattribute__', '__hash__', '__init__', '__iter__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 'close', 'closed', 'encoding', 'fileno', 'flush', 'isatty', 'mode', 'name', 'newlines', 'next', 'read', 'readinto', 'readline', 'readlines', 'seek', 'softspace', 'tell', 'truncate', 'write', 'writelines', 'xreadlines']
>>> 
>>> dir(file)
['__class__', '__delattr__', '__doc__', '__enter__', '__exit__', '__getattribute__', '__hash__', '__init__', '__iter__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 'close', 'closed', 'encoding', 'fileno', 'flush', 'isatty', 'mode', 'name', 'newlines', 'next', 'read', 'readinto', 'readline', 'readlines', 'seek', 'softspace', 'tell', 'truncate', 'write', 'writelines', 'xreadlines']
>>> 
>>> 
>>> 
>>> 
>>> b = open('data.bin', 'wb')
>>> import struct
>>> data = struct.pack('>i4sh', 8, 'spam', 9)
>>> data
'\x00\x00\x00\x08spam\x00\t'
>>> b.write(data)
>>> b.close()
>>> 
>>> b = open('data.bin', 'rb')
>>> bytes = b.read()
>>> bytes
'\x00\x00\x00\x08spam\x00\t'
>>> 
>>> vals = struct.unpack('>i4sh', bytes)
>>> vals
(8, 'spam', 9)
>>> x = vals[0]
>>> x
8
>>> x & 0x1
0
>>> x
8
>>> hex(x)
'0x8'
>>> x & 0x8
8
>>> 
>>> X = None
>>> 
>>> L = []
>>> L[99]

Traceback (most recent call last):
  File "<pyshell#334>", line 1, in <module>
    L[99]
IndexError: list index out of range
>>> 
>>> L[99] = 1

Traceback (most recent call last):
  File "<pyshell#336>", line 1, in <module>
    L[99] = 1
IndexError: list assignment index out of range
>>> 
>>> L = [None] * 100
>>> L
[None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None]
>>> 
>>> type(L)
<type 'list'>
>>> 
>>> type(type(L))
<type 'type'>
>>> 
>>> 
>>> str = '42
SyntaxError: EOL while scanning single-quoted string
>>> 
>>> 
>>> S = '42'
>>> I = 1
>>> 
>>> S + I

Traceback (most recent call last):
  File "<pyshell#352>", line 1, in <module>
    S + I
TypeError: cannot concatenate 'str' and 'int' objects
>>> 
>>> int(S)
42
>>> int(S) + I
43
>>> str(I)
'1'
>>> S + str(I)
'421'
>>> int('abcd')

Traceback (most recent call last):
  File "<pyshell#358>", line 1, in <module>
    int('abcd')
ValueError: invalid literal for int() with base 10: 'abcd'
>>> 
>>> int('ABCDEF', 16)
11259375
>>> int('10101', 2)
21
>>> ================================ RESTART ================================
>>> 
Enter age:40
1600
Enter age:6
36
Enter age:199
39601
Enter age:stop
bye
>>> ================================ RESTART ================================
>>> 
Enter age:abc

Traceback (most recent call last):
  File "C:/Python25/interact.py", line 4, in <module>
    num = int(inp)
ValueError: invalid literal for int() with base 10: 'abc'
>>> 
>>> inp = '1234'
>>> inp.isdigit()
True
>>> ================================ RESTART ================================
>>> 
Enter age:30
900
Enter age:abc
Bad!Bad!Bad!Bad!Bad!Bad!Bad!Bad!
Enter age:5
25
Enter age:stop
bye
>>> 

>>> x

Traceback (most recent call last):
  File "<pyshell#366>", line 1, in <module>
    x
NameError: name 'x' is not defined
>>> 
>>> x = y = 0
>>> x
0
>>> y
0
>>> x = x + 1
>>> x
1
>>> y
0
>>> x = y = []
>>> x
[]
>>> y
[]
>>> x.append(42)
>>> x
[42]
>>> y
[42]
>>> x, y = [], []
>>> x.append(99)
>>> x
[99]
>>> y
[]
>>> 
>>> 
>>> x = 0
>>> x = x + 1
>>> x = x + 1
>>> x
2
>>> 
>>> x += 1
>>> x += 1
>>> x
4
>>> 
>>> 
>>> L = [1, 2]
>>> L.append(3)
>>> L
[1, 2, 3]
>>> 
>>> L = L.append(4)
>>> print L
None
>>> 
>>> D

Traceback (most recent call last):
  File "<pyshell#403>", line 1, in <module>
    D
NameError: name 'D' is not defined
>>> 
>>> D = {'a': 1, 'b': 2, 'c': 3}
>>> D
{'a': 1, 'c': 3, 'b': 2}
>>> 
>>> for key in D.keys().sort():
	print key, D[key]

	

Traceback (most recent call last):
  File "<pyshell#411>", line 1, in <module>
    for key in D.keys().sort():
TypeError: 'NoneType' object is not iterable
>>> 
>>> for key in sorted(D):
	print key, D[key]

	
a 1
b 2
c 3
>>> D
{'a': 1, 'c': 3, 'b': 2}
>>> 
>>> ord('s')
115
>>> ord('spam')

Traceback (most recent call last):
  File "<pyshell#419>", line 1, in <module>
    ord('spam')
TypeError: ord() expected a character, but string of length 4 found
>>> 
>>> S = 'spam'
>>> for ch in S:
	print ord(ch)

	
115
112
97
109
>>> help(ord)
Help on built-in function ord in module __builtin__:

ord(...)
    ord(c) -> integer
    
    Return the integer ordinal of a one-character string.

>>> import sys
>>> tmp = sys.stdout
>>> sys.stdout = open('output')
>>> print 42

Traceback (most recent call last):
  File "<pyshell#429>", line 1, in <module>
    print 42
IOError: [Errno 0] Error
>>> 
>>> import sys
>>> tmp = sys.stdout
>>> sys.stdout = open('output', 'w')
>>> print 42
>>> print 'spam'
>>> sys.stdout = tmp
>>> print 99

Traceback (most recent call last):
  File "<pyshell#437>", line 1, in <module>
    print 99
IOError: [Errno 0] Error
>>> 
