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      
>>> 
>>> 2 ** 100
1267650600228229401496703205376L
>>> 
>>> 'spam' * 80
'spamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspamspam'
>>> 
>>> import sys
>>> sys.platform
'win32'
>>> 
>>> 
>>> ================================ RESTART ================================
>>> 
3273390607896141870013189696827599152216642046043064789483291368096133796404674554883270092325904157150886684127560071009217256545885393053328527589376
C:\Python25
spam!NI
>>> ================================ RESTART ================================
>>> 
3273390607896141870013189696827599152216642046043064789483291368096133796404674554883270092325904157150886684127560071009217256545885393053328527589376
C:\Python25
spam!NI
>>> ================================ RESTART ================================
>>> 
3273390607896141870013189696827599152216642046043064789483291368096133796404674554883270092325904157150886684127560071009217256545885393053328527589376
C:\Python25

Traceback (most recent call last):
  File "C:\Python25\scr1.py", line 5, in <module>
    x = 'spam!' + Z
NameError: name 'Z' is not defined
>>> 1.py", line 5, in <module>
    x = 'spam!' + Z
NameError: name 'Z' is not defined
>>>
SyntaxError: invalid syntax

>>> 
>>> 
>>> 
>>> ================================ RESTART ================================
>>> 
3273390607896141870013189696827599152216642046043064789483291368096133796404674554883270092325904157150886684127560071009217256545885393053328527589376
C:\Python25
spam!NI
>>> 
>>> import scr1
3273390607896141870013189696827599152216642046043064789483291368096133796404674554883270092325904157150886684127560071009217256545885393053328527589376
C:\Python25
spam!NI
>>> 
>>> import scr1
>>> import scr1
>>> import scr1
>>> import scr1
>>> reload(scr1)
141246703213942603683520966701614733366889617518454111681368808585711816984270751255808912631671152637335603208431366082764203838069979338335971185726639923431051777851865399011877999645131707069373498212631323752553111215372844035950900535954860733418453405575566736801565587405464699640499050849699472357900905617571376618228216434213181520991556677126498651782204174061830939239176861341383294018240225838692725596147005144243281075275629495339093813198966735633606329691023842454125835888656873133981287240980008838073668221804264432910894030789020219440578198488267339768238872279902157420307247570510423845868872596735891805818727796435753018518086641356012851302546726823009250218328018251907340245449863183265637987862198511046362985461949587281119139907228004385942880953958816554567625296086916885774828934449941362416588675326940332561103664556982622206834474219811081872404929503481991376740379825998791411879802717583885498575115299471743469241117070230398103378615232793710290992656444842895511830355733152020804157920090041811951880456705515468349446182731742327685989277607620709525878318766488368348965015474997864119765441433356928012344111765735336393557879214937004347568208665958717764059293592887514292843557047089164876483116615691886203812997555690171892169733755224469032475078797830901321579940127337210694377283439922280274060798234786740434893458120198341101033812506720046609891160700284002100980452964039788704335302619337597862052192280371481132164147186514169090917191909376
C:\Python25
spam!NI
<module 'scr1' from 'C:\Python25\scr1.py'>
>>> ================================ RESTART ================================
>>> 
141246703213942603683520966701614733366889617518454111681368808585711816984270751255808912631671152637335603208431366082764203838069979338335971185726639923431051777851865399011877999645131707069373498212631323752553111215372844035950900535954860733418453405575566736801565587405464699640499050849699472357900905617571376618228216434213181520991556677126498651782204174061830939239176861341383294018240225838692725596147005144243281075275629495339093813198966735633606329691023842454125835888656873133981287240980008838073668221804264432910894030789020219440578198488267339768238872279902157420307247570510423845868872596735891805818727796435753018518086641356012851302546726823009250218328018251907340245449863183265637987862198511046362985461949587281119139907228004385942880953958816554567625296086916885774828934449941362416588675326940332561103664556982622206834474219811081872404929503481991376740379825998791411879802717583885498575115299471743469241117070230398103378615232793710290992656444842895511830355733152020804157920090041811951880456705515468349446182731742327685989277607620709525878318766488368348965015474997864119765441433356928012344111765735336393557879214937004347568208665958717764059293592887514292843557047089164876483116615691886203812997555690171892169733755224469032475078797830901321579940127337210694377283439922280274060798234786740434893458120198341101033812506720046609891160700284002100980452964039788704335302619337597862052192280371481132164147186514169090917191909376
C:\Python25
spam!NI
>>> 
>>> 1 > 0
True
>>> 
>>> True + 2
3
>>> X = 99
>>> 
>>> print 42
42
>>> 
>>> X
99
>>> X = 'spam'
>>> 
>>> 
>>> S = '42'
>>> S
'42'
>>> int(S)
42
>>> S = 'spam'
>>> 
>>> len(S)
4
>>> S + 'NI"
SyntaxError: EOL while scanning single-quoted string
>>> 
>>> S + 'NI'
'spamNI'
>>> 
>>> S
'spam'
>>> 
>>> S * 8
'spamspamspamspamspamspamspamspam'
>>> 
>>> S
'spam'
>>> S[0]
's'
>>> S[1]
'p'
>>> S[-1]
'm'
>>> S[-2]
'a'
>>> 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 + 'NI'
'spamNI'
>>> 
>>> S
'spam'
>>> S[0]
's'
>>> 
>>> S[0] = 'x'

Traceback (most recent call last):
  File "<pyshell#74>", line 1, in <module>
    S[0] = 'x'
TypeError: 'str' object does not support item assignment
>>> 
>>> 
>>> S
'spam'
>>> 
>>> S.find('pa')
1
>>> 
>>> S.replace('pa', 'XYZ')
'sXYZm'
>>> 
>>> S
'spam'
>>> line = 'aaa,bbbbb,cc'
>>> line.split(',')
['aaa', 'bbbbb', 'cc']
>>> 
>>> line = 'aaa,bbbbb,cc\n'
>>> line[:-1]
'aaa,bbbbb,cc'
>>> 
>>> line
'aaa,bbbbb,cc\n'
>>> lijne.rstrip()

Traceback (most recent call last):
  File "<pyshell#91>", line 1, in <module>
    lijne.rstrip()
NameError: name 'lijne' is not defined
>>> line.rstrip()
'aaa,bbbbb,cc'
>>> 
>>> 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.partition)
Help on built-in function partition:

partition(...)
    S.partition(sep) -> (head, sep, tail)
    
    Searches for the separator sep in S, and returns the part before it,
    the separator itself, and the part after it.  If the separator is not
    found, returns S and two empty strings.

>>> 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.getcwd)
Help on built-in function getcwd in module nt:

getcwd(...)
    getcwd() -> path
    
    Return a string representing the current working directory.

>>> help(''.endswith)
Help on built-in function endswith:

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

>>> 
>>> help(str.startswith)
Help on method_descriptor:

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.

>>> L = [123, 'spam', 1.23]
>>> 
>>> len(L)
3
>>> L + [5, 6, 7]
[123, 'spam', 1.23, 5, 6, 7]
>>> L * 8
[123, 'spam', 1.23, 123, 'spam', 1.23, 123, 'spam', 1.23, 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:]
['spam', 1.23]
>>> L
[123, 'spam', 1.23]
>>> 
>>> L[2] = 'NI'
>>> L
[123, 'spam', 'NI']
>>> 
>>> L.append(99)
>>> L
[123, 'spam', 'NI', 99]
>>> L.remove('NI')
>>> L
[123, 'spam', 99]
>>> 
>>> 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
>>> col = [row[1] for row in M]
>>> col
[2, 5, 8]
>>> 
>>> [c * 4 for c in 'spam']
['ssss', 'pppp', 'aaaa', 'mmmm']
>>> 

>>> D = {}
>>> D['name'] = 'Bob'
>>> D['job']  = 'dev'
>>> D['age']  = 40
>>> 
>>> 
>>> D
{'age': 40, 'job': 'dev', 'name': 'Bob'}
>>> 
>>> print D['name']
Bob
>>> S = 'age'
>>> D[S]
40
>>> 
>>> rec = {'name': {'first': 'Bob', 'last': 'Smith'},
           'job':  ['dev', 'mgr'],
           'age':  40.5}
>>> 
>>> rec['name']
{'last': 'Smith', 'first': 'Bob'}
>>> rec['name']['last']
'Smith'
>>> 
>>> rec['job']
['dev', 'mgr']
>>> rec['job'][-1]
'mgr'
>>> 
>>> rec['job'].append('janitor')
>>> 
>>> rec
{'age': 40.5, 'job': ['dev', 'mgr', 'janitor'], 'name': {'last': 'Smith', 'first': 'Bob'}}
>>> 
>>> rec = 0
>>> 
>>> class rec: pass

>>> rec.name = 'Bob'
>>> rec.age  = 40
>>> 
>>> rec.name
'Bob'
>>> 
>>> D
{'age': 40, 'job': 'dev', 'name': 'Bob'}
>>> 
>>> D['title']

Traceback (most recent call last):
  File "<pyshell#175>", line 1, in <module>
    D['title']
KeyError: 'title'
>>> 
>>> D.has_key('title')
False
>>> 
>>> if not D.has_key('title'):
	print 'missing'

	
missing
>>> 
>>> if not 'title' in D
	print 'missing'
	
SyntaxError: invalid syntax
>>> 
>>> 
>>> if not 'title' in D:
	print 'missing'

	
missing
>>> 
>>> D
{'age': 40, 'job': 'dev', 'name': 'Bob'}
>>> D.get('title', 'missing')
'missing'
>>> 
>>> D.get('name', 'missing')
'Bob'
>>> 
>>> 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
>>> D
{'a': 1, 'c': 3, 'b': 2}
>>> 
>>> 
>>> 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

>>> T = (1, 2, 3)
>>> len(T)
3
>>> T[1:]
(2, 3)
>>> 
>>> T + (4, 5, 6)
(1, 2, 3, 4, 5, 6)
>>> 
>>> T[0]
1
>>> T[0] = 99

Traceback (most recent call last):
  File "<pyshell#220>", line 1, in <module>
    T[0] = 99
TypeError: 'tuple' object does not support item assignment
>>> 
>>> help(open)
Help on built-in function open in module __builtin__:

open(...)
    open(name[, mode[, buffering]]) -> file object
    
    Open a file using the file() type, returns a file object.

>>> 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']
>>> 
>>> 
>>> f open('data.txt', 'w')
SyntaxError: invalid syntax
>>> 
>>> f = open('data.txt', 'w')
>>> 
>>> f.write('Hello\n')
>>> f.write('world\n')
>>> f.close()
>>> 
>>> f = open('data.txt')
>>> bytes = f.read()
>>> bytes
'Hello\nworld\n'
>>> 
>>> print bytes
Hello
world

>>> L = [1, 2, 3, 4]
>>> T = tuple(L)
>>> T
(1, 2, 3, 4)
>>> 
>>> L
[1, 2, 3, 4]
>>> 
>>> T
(1, 2, 3, 4)
>>> 
>>> M = list(T)
>>> M
[1, 2, 3, 4]
>>> 
>>> T
(1, 2, 3, 4)
>>> dir(T)
['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmul__', '__setattr__', '__str__']
>>> 
>>> 
>>> S = '42'
>>> I = 1
>>> 
>>> S + I

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

>>> 
>>> 
>>> X = 99
>>> X = 'spam'
>>> X = 1/23
>>> X = 1.23
>>> 
>>> L = [1, 2, 3]
>>> M = L
>>> 
>>> L == M
True
>>> L is M
True
>>> 
>>> L = [1, 2, 3]
>>> M = L[:]
>>> L == M
True
>>> L is M
False
>>> M
[1, 2, 3]
>>> 
>>> import sys
>>> sys.getrefcount(L)
2
>>> 
>>> sys.getrefcount(1)
780
>>> 
>>> X = 42
>>> Y = 42
>>> 
>>> X == Y
True
>>> X is Y
True
>>> 
>>> X = 'spam'
>>> Y = 's' + 'pam'
>>> X == Y
True
>>> Xs Y
SyntaxError: invalid syntax
>>> X is Y
True
>>> 
>>> S = 'A\nB\tC'
>>> 
>>> len(S)
5
>>> ord('\n')
10
>>> S = 'A\0B\0C'
>>> 
>>> len(S)
5
>>> msg = """
aaaaaaaaaaaaaaaaaaaa
bbbbbbbb'''bbbbb""bbbbbbbbbb
cccccccc"""
>>> 
>>> msg
'\naaaaaaaaaaaaaaaaaaaa\nbbbbbbbb\'\'\'bbbbb""bbbbbbbbbb\ncccccccc'
>>> 
>>> print msg

aaaaaaaaaaaaaaaaaaaa
bbbbbbbb'''bbbbb""bbbbbbbbbb
cccccccc
>>> open(r'C:\new\text')  
KeyboardInterrupt
>>> 

>>> 
>>> f = open('data.bin', 'wb')
>>> import struct
>>> data = struct.pack('>i4sh', 6, 'spam', 7)
>>> data
'\x00\x00\x00\x06spam\x00\x07'
>>> f.write(data)
>>> f.close()
>>> 
>>> f = open('data.bin', 'rb')
>>> bytes = f.read()
>>> bytes
'\x00\x00\x00\x06spam\x00\x07'
>>> 
>>> vals = struct.unpack('>i4sh', bytes)
>>> vals
(6, 'spam', 7)
>>> 
>>> struct.unpack('i' * 1000, bytes) 
KeyboardInterrupt
>>> 
>>> import struct
>>> help(struct)
Help on module struct:

NAME
    struct

FILE
    c:\python25\lib\struct.py

DESCRIPTION
    Functions to convert between Python values and C structs.
    Python strings are used to hold the data representing the C struct
    and also as format strings to describe the layout of data in the C struct.
    
    The optional first format char indicates byte order, size and alignment:
     @: native order, size & alignment (default)
     =: native order, std. size & alignment
     <: little-endian, std. size & alignment
     >: big-endian, std. size & alignment
     !: same as >
    
    The remaining chars indicate types of args and must match exactly;
    these can be preceded by a decimal repeat count:
     x: pad byte (no data); c:char; b:signed byte; B:unsigned byte;
     h:short; H:unsigned short; i:int; I:unsigned int;
     l:long; L:unsigned long; f:float; d:double.
    Special cases (preceding decimal count indicates length):
     s:string (array of char); p: pascal string (with count byte).
    Special case (only available in native format):
     P:an integer type that is wide enough to hold a pointer.
    Special case (not in native mode unless 'long long' in platform C):
     q:long long; Q:unsigned long long
    Whitespace between formats is ignored.
    
    The variable struct.error is an exception raised on errors.

CLASSES
    exceptions.Exception(exceptions.BaseException)
        error
    
    class error(exceptions.Exception)
     |  Method resolution order:
     |      error
     |      exceptions.Exception
     |      exceptions.BaseException
     |      __builtin__.object
     |  
     |  Data descriptors defined here:
     |  
     |  __weakref__
     |      list of weak references to the object (if defined)
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from exceptions.Exception:
     |  
     |  __init__(...)
     |      x.__init__(...) initializes x; see x.__class__.__doc__ for signature
     |  
     |  ----------------------------------------------------------------------
     |  Data and other attributes inherited from exceptions.Exception:
     |  
     |  __new__ = <built-in method __new__ of type object at 0x1E1CABE0>
     |      T.__new__(S, ...) -> a new object with type S, a subtype of T
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from exceptions.BaseException:
     |  
     |  __delattr__(...)
     |      x.__delattr__('name') <==> del x.name
     |  
     |  __getattribute__(...)
     |      x.__getattribute__('name') <==> x.name
     |  
     |  __getitem__(...)
     |      x.__getitem__(y) <==> x[y]
     |  
     |  __reduce__(...)
     |  
     |  __repr__(...)
     |      x.__repr__() <==> repr(x)
     |  
     |  __setattr__(...)
     |      x.__setattr__('name', value) <==> x.name = value
     |  
     |  __setstate__(...)
     |  
     |  __str__(...)
     |      x.__str__() <==> str(x)
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from exceptions.BaseException:
     |  
     |  __dict__
     |  
     |  args
     |  
     |  message
     |      exception message

FUNCTIONS
    calcsize(fmt)
        Return size of C struct described by format string fmt.
        See struct.__doc__ for more on format strings.
    
    pack(fmt, *args)
        Return string containing values v1, v2, ... packed according to fmt.
        See struct.__doc__ for more on format strings.
    
    pack_into(fmt, buf, offset, *args)
        Pack the values v1, v2, ... according to fmt, write
        the packed bytes into the writable buffer buf starting at offset.
        See struct.__doc__ for more on format strings.
    
    unpack(fmt, s)
        Unpack the string, containing packed C structure data, according
        to fmt.  Requires len(string)==calcsize(fmt).
        See struct.__doc__ for more on format strings.
    
    unpack_from(fmt, buf, offset=0)
        Unpack the buffer, containing packed C structure data, according to
        fmt starting at offset. Requires len(buffer[offset:]) >= calcsize(fmt).
        See struct.__doc__ for more on format strings.

DATA
    __version__ = '0.1'

VERSION
    0.1


>>> 
>>> X = None
>>> print X
None
>>> 
>>> L = []
>>> L[99]

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

Traceback (most recent call last):
  File "<pyshell#343>", 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(None)
<type 'NoneType'>
>>> 
>>> type(type(L))
<type 'type'>
>>> 
>>> 
>>> props = {'name': 'Bob', 'age': 40, 'job': ['dev', 'mgr']}
>>> 
>>> import pickle
>>> pickle.dump(props, open('props.pkl'))

Traceback (most recent call last):
  File "<pyshell#358>", line 1, in <module>
    pickle.dump(props, open('props.pkl'))
IOError: [Errno 2] No such file or directory: 'props.pkl'
>>> 
>>> props = {'name': 'Bob', 'age': 40, 'job': ['dev', 'mgr']}
>>> 
>>> import pickle
>>> pickle.dump(props, open('props.pkl', 'w'))
>>> 
>>> rec = pickle.load(open('props.pkl'))
>>> rec
{'job': ['dev', 'mgr'], 'age': 40, 'name': 'Bob'}
>>> 
>>> print open('props.pkl').read()
(dp0
S'job'
p1
(lp2
S'dev'
p3
aS'mgr'
p4
asS'age'
p5
I40
sS'name'
p6
S'Bob'
p7
s.
>>> 
>>> L = [1, 2, 3]
>>> L.append([4])
>>> L
[1, 2, 3, [4]]
>>> ================================ RESTART ================================
>>> 
{'age': '42\n', 'job': 'dev\n', 'name': 'Bob\n'}
>>> ================================ RESTART ================================
>>> 
{'age': '42', 'job': 'dev', 'name': 'Bob'}
>>> 
>>> 
>>> inp = raw_input('Enter:')
Enter:abcdefgh
>>> inp
'abcdefgh'
>>> 
>>> ================================ RESTART ================================
>>> 
Enter age:40
1600
Enter age:5
25
Enter age:stop
bye
>>> 
>>> ================================ RESTART ================================
>>> 
Enter age:xyz

Traceback (most recent call last):
  File "C:/Python25/inter.py", line 4, in <module>
    print int(inp) ** 2
ValueError: invalid literal for int() with base 10: 'xyz'
>>> 
>>> 
>>> inp = 'xyz'
>>> inp.isdigit()
False
>>> inp = '1.23'
>>> inp.isdigit()
False
>>> int(inp)

Traceback (most recent call last):
  File "<pyshell#385>", line 1, in <module>
    int(inp)
ValueError: invalid literal for int() with base 10: '1.23'
>>> float(inp)
1.23
>>> 
>>> inp
'1.23'
>>> eval(inp)
1.23
>>> eval('2 ** 32')
4294967296L
>>> 
>>> eval('__import__("os").system("rm -rf *")')
KeyboardInterrupt
>>> 
>>> ================================ RESTART ================================
>>> 
Enter age:45
2025
Enter age:6
36
Enter age:xyz
Bad!Bad!Bad!Bad!Bad!Bad!Bad!Bad!
Enter age:7
49
Enter age:stop
bye
>>> ================================ RESTART ================================
>>> 
Enter age:6
low
Enter age:35
1225
Enter age:xxx
Bad!Bad!Bad!Bad!Bad!Bad!Bad!Bad!
Enter age:stop
bye
>>> ================================ RESTART ================================
>>> 
Enter age:STOP
bye
>>> 
>>> 
>>> D

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

	
a 1
b 2
c 3
>>> 
>>> D
{'a': 1, 'c': 3, 'b': 2}
>>> for key in sorted(D):
	print key, D[key]

	
a 1
b 2
c 3
>>> 
>>> L = [1, 2, 3, 4, 5]
>>> while L:
	front, L = L[0], L[1:]
	print front, L

	
1 [2, 3, 4, 5]
2 [3, 4, 5]
3 [4, 5]
4 [5]
5 []
>>> 
>>> 
>>> X = Y = 0
>>> X = X + 1
>>> X
1
>>> Y
0
>>> X = Y = []
>>> X.append(1)
>>> X
[1]
>>> Y
[1]
>>> X, Y = [], []
>>> 
>>> L = [1, 2, 3]
>>> L.append(4)
>>> L
[1, 2, 3, 4]
>>> 
>>> L = L.append(5)
>>> print L
None
>>> 
>>> D
{'a': 1, 'c': 3, 'b': 2}
>>> 
>>> for key in D.keys().sort():
	print key, D[key]

	

Traceback (most recent call last):
  File "<pyshell#442>", line 1, in <module>
    for key in D.keys().sort():
TypeError: 'NoneType' object is not iterable
>>> 
>>> import sys
>>> print >> sys.stderr, 'Bad!' * 20
Bad!Bad!Bad!Bad!Bad!Bad!Bad!Bad!Bad!Bad!Bad!Bad!Bad!Bad!Bad!Bad!Bad!Bad!Bad!Bad!
>>> 
>>> D
{'a': 1, 'c': 3, 'b': 2}
>>> D.values()
[1, 3, 2]
>>> 
>>> V = D.values()
>>> V.sort()
>>> V
[1, 2, 3]
>>> 
>>> import docstrings
>>> print docstrings.__doc__

Module documentation
Words Go Here

>>> print docstrings.square.__doc__

    function documentation
    can we have your liver then?
    
>>> help(docstrings)
Help on module docstrings:

NAME
    docstrings

FILE
    c:\python25\docstrings.py

DESCRIPTION
    Module documentation
    Words Go Here

FUNCTIONS
    square(x)
        function documentation
        can we have your liver then?

DATA
    spam = 40


>>> help(docstrings.square)
Help on function square in module docstrings:

square(x)
    function documentation
    can we have your liver then?

>>> f = open('scr1.py')
>>> f.readline()
'# words go here\n'
>>> f.readline()
'print 2 ** 5000\n'
>>> f.readline()
'import os\n'
>>> f.readline()
'print os.getcwd()     # current dir\n'
>>> f.readline()
"x = 'spam!'\n"
>>> f.readline()
"print x + 'NI'\n"
>>> f.readline()
'raw_input()\n'
>>> f.readline()
''
>>> f = open('scr1.py')
>>> f.next()
'# words go here\n'
>>> f.next()
'print 2 ** 5000\n'
>>> f.next()
'import os\n'
>>> f.next()
'print os.getcwd()     # current dir\n'
>>> f.next()
"x = 'spam!'\n"
>>> f.next()
"print x + 'NI'\n"
>>> f.next()
'raw_input()\n'
>>> f.next()

Traceback (most recent call last):
  File "<pyshell#476>", line 1, in <module>
    f.next()
StopIteration
>>> 
>>> for line in open('scr1.py'):
	print line.upper(),

	
# WORDS GO HERE
PRINT 2 ** 5000
IMPORT OS
PRINT OS.GETCWD()     # CURRENT DIR
X = 'SPAM!'
PRINT X + 'NI'
RAW_INPUT()
>>> 
>>> for line in open('scr1.py').readlines():
	print line.upper(),

	
# WORDS GO HERE
PRINT 2 ** 5000
IMPORT OS
PRINT OS.GETCWD()     # CURRENT DIR
X = 'SPAM!'
PRINT X + 'NI'
RAW_INPUT()
>>> 
>>> L
>>> L = [1, 2, 3, 4]
>>> 
>>> I = iter(L)
>>> I.next()
1
>>> I.next()
2
>>> I.next()
3
>>> I.next()
4
>>> I.next()

Traceback (most recent call last):
  File "<pyshell#493>", line 1, in <module>
    I.next()
StopIteration
>>> 
>>> L
[1, 2, 3, 4]
>>> 
>>> I = iter(L)
>>> while True:
	try:
	    X = I.next()
	    print X
	except StopIteration:
	    break

	
1
2
3
4
>>> for x in L:
	print x

	
1
2
3
4
>>> 
>>> D
{'a': 1, 'c': 3, 'b': 2}
>>> 
>>> for k in D.keys():
	print k, D[k]

	
a 1
c 3
b 2
>>> for k in D:
	print k, D[k]

	
a 1
c 3
b 2
>>> 'a' in D
True
>>> 'a' in D.keys()
True
>>> 
>>> range(1, 10)
[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> range(1, 10, -1)
[]
>>> 
>>> range(10, 1, -1)
[10, 9, 8, 7, 6, 5, 4, 3, 2]
>>> 
>>> X[I:J:K]  
KeyboardInterrupt
>>> 
>>> S = 'abcdefghijkl,mnop'
>>> 
>>> S[::2]
'acegik,np'
>>> S[::3]
'adgj,o'
>>> S[1::2]
'bdfhjlmo'
>>> 
>>> S[::-1]
'ponm,lkjihgfedcba'
>>> 
>>> 
>>> L = [1, 2, 3, 4]
>>> 
>>> for x in L:
	x += 10

	
>>> L
[1, 2, 3, 4]
>>> x
14
>>> for i in range(len(L)):
	L[i] += 10

	
>>> L
[11, 12, 13, 14]
>>> 
>>> M = [x + 10 for x in L]
>>> M
[21, 22, 23, 24]
>>> 
>>> 
>>> f = open('scr1.py')
>>> lines = f.readlines()
>>> lines
['# words go here\n', 'print 2 ** 5000\n', 'import os\n', 'print os.getcwd()     # current dir\n', "x = 'spam!'\n", "print x + 'NI'\n", 'raw_input()\n']
>>> 
>>> lines = [line.rstrip() for line in lines]
>>> 
>>> lines
['# words go here', 'print 2 ** 5000', 'import os', 'print os.getcwd()     # current dir', "x = 'spam!'", "print x + 'NI'", 'raw_input()']
>>> 
>>> lines = [line.rstrip() for line in open('scr1.py')]
>>> lines
['# words go here', 'print 2 ** 5000', 'import os', 'print os.getcwd()     # current dir', "x = 'spam!'", "print x + 'NI'", 'raw_input()']
>>> 
>>> lines = [line.rstrip() for line in open('scr1.py') if line[0] == 'p']
>>> lines
['print 2 ** 5000', 'print os.getcwd()     # current dir', "print x + 'NI'"]
>>> 
>>> lines = [line[5:] for line in open('scr1.py') if line[0] == 'p']
>>> lines
[' 2 ** 5000\n', ' os.getcwd()     # current dir\n', " x + 'NI'\n"]
>>> 
>>> lines = [line.rstrip().replace('print', 'SPAM') for line in open('scr1.py') if line[0] == 'p']
>>> lines
['SPAM 2 ** 5000', 'SPAM os.getcwd()     # current dir', "SPAM x + 'NI'"]
>>> 
>>> [x + y for x in 'abc' for y in 'lmn']
['al', 'am', 'an', 'bl', 'bm', 'bn', 'cl', 'cm', 'cn']
>>> 
>>> L
[11, 12, 13, 14]
>>> M = [x + 10 for x in L]
>>> 
>>> res = []
>>> for x in L:
	res.append(x + 10)

	
>>> res
[21, 22, 23, 24]
>>> 
>>> res = []
>>> for x in 'abc':
	for y in 'lmn':
		res.append(x + y)

		
>>> res
['al', 'am', 'an', 'bl', 'bm', 'bn', 'cl', 'cm', 'cn']
>>> 
>>> import __builtin__
SyntaxError: invalid syntax
>>> 
>>> import __builtin__
>>> dir(__builtin__)
['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError', 'Exception', 'False', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError', 'PendingDeprecationWarning', 'ReferenceError', 'RuntimeError', 'RuntimeWarning', 'StandardError', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'True', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', 'ValueError', 'Warning', 'WindowsError', 'ZeroDivisionError', '_', '__debug__', '__doc__', '__import__', '__name__', 'abs', 'all', 'any', 'apply', 'basestring', 'bool', 'buffer', 'callable', 'chr', 'classmethod', 'cmp', 'coerce', 'compile', 'complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'execfile', 'exit', 'file', 'filter', 'float', 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id', 'input', 'int', 'intern', 'isinstance', 'issubclass', 'iter', 'len', 'license', 'list', 'locals', 'long', 'map', 'max', 'min', 'object', 'oct', 'open', 'ord', 'pow', 'property', 'quit', 'range', 'raw_input', 'reduce', 'reload', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'unichr', 'unicode', 'vars', 'xrange', 'zip']
>>> 
>>> open = 42
>>> open
42
>>> del open
>>> open
<built-in function open>
>>> 
>>> file = open(.....)
KeyboardInterrupt
>>> 
>>> True = False
>>> __builtin__.open
<built-in function open>
>>> 
>>> __builtin__.open is open
True
>>> __builtin__.True = False

Traceback (most recent call last):
>>> ================================ RESTART ================================
>>> 

>>> def maker(N):
	def action(X):
		return X ** N
	return action

>>> f = maker(3)
>>> f
<function action at 0x00BB8830>
>>> 
>>> f(2)
8
>>> g = maker(4)
>>> g(2)
16
>>> 
>>> f(2)
8
>>> def func(*args):
	print args

	
>>> func()
()
>>> args(1, 2)

Traceback (most recent call last):
  File "<pyshell#622>", line 1, in <module>
    args(1, 2)
NameError: name 'args' is not defined
>>> func (1, 2)
(1, 2)
>>> 
>>> func (1, 2, 3, 4, 5)
(1, 2, 3, 4, 5)
>>> 
>>> def func(*args):
	tot = 0
	for x in args: tot += x
	return x

>>> 
>>> def func(*args):
	tot = 0
	for x in args: tot += x
	return tot

>>> func(1, 2,3, 4)
10
>>> 
>>> func('a', 'b')

Traceback (most recent call last):
  File "<pyshell#637>", line 1, in <module>
    func('a', 'b')
  File "<pyshell#634>", line 3, in func
    for x in args: tot += x
TypeError: unsupported operand type(s) for +=: 'int' and 'str'
>>> 
>>> def func(*args):
	tot = args[0]
	for x in args[1:]: tot += x
	return tot

>>> func(1, 2,3, 4)
10
>>> func('a', 'b')
'ab'
>>> 
>>> 
>>> fname = 'README.txt'
>>> 
>>> len( open(fname).read() )
55400
>>> 
>>> len( open(fname).readlines() )
1291
>>> 
>>> tot = 0
>>> for line in open(fname): tot += 1

>>> tot
1291
>>> 
>>> tot = 0
>>> for line in open(fname): tot += len(line)

>>> tot
55400
>>> 
>>> def countChars(fname):
	tot = 0
	for line in open(fname): tot += 1
	return tot

>>> def test():
	fname = raw_input('File name?')
	print countChars(fname)

	
>>> test()
File name?README.txt
1291
>>> ================================ RESTART ================================
>>> 
>>> ================================ RESTART ================================
>>> 
I am: __main__
File name?README.txt
55400
>>> 
>>> import wc
I am: wc
>>> wc.test()
File name?README.txt
55400
>>> 
>>> import sys
>>> sys.path
['C:/Python25', '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 ================================
>>> 

Traceback (most recent call last):
  File "C:/Python25/person.py", line 8, in <module>
    bob = Person('Bob Smith')
TypeError: __init__() takes at least 3 arguments (2 given)
>>> ================================ RESTART ================================
>>> 
Bob Smith 100000
>>> 
>>> 
>>> name = 'Bob Smith'
>>> name.split()
['Bob', 'Smith']
>>> name.split()[-1]
'Smith'
>>> ================================ RESTART ================================
>>> 
Bob Smith 100000
Smith
110000.0
>>> ================================ RESTART ================================
>>> 
Bob Smith 100000
Smith Jones
110000.0
>>> ================================ RESTART ================================
>>> 
Bob Smith 100000
Smith Jones
110000.0
<__main__.Person instance at 0x00BB9558>
>>> ================================ RESTART ================================
>>> 
[Person: Bob Smith, 0]
[Person: Sue Jones, 100000]
Smith Jones
[Person: Sue Jones, 110000.0]
>>> ================================ RESTART ================================
>>> 
[Person: Bob Smith, 0]
[Person: Sue Jones, 100000]
Smith Jones
[Person: Sue Jones, 110000.0]
[Person: Tom Jones, 60000.0]
>>> ================================ RESTART ================================
>>> 
[Person: Bob Smith, 0]
[Person: Sue Jones, 100000]
Smith Jones
[Person: Sue Jones, 110000.0]
[Person: Tom Jones, 60000.0]
>>> 
>>> def __cmp__
KeyboardInterrupt
>>> 
>>> def __lt__  < 
KeyboardInterrupt
>>> ================================ RESTART ================================
>>> 
>>> import glob
>>> glob.glob('lgmt*08*')
['lgmt0108db']
>>> 
>>> import shelve
>>> db = shelve.open('lgmt0108db')
>>> 
>>> len(db)
3
>>> db.keys()
['tom', 'bob', 'sue']
>>> 
>>> x = db['bob']
>>> print x
[Person: Bob Smith, 0]
>>> 
>>> for key in db:
	print key, '=>', db[key]

	
tom => [Person: Tom Jones, 50000]
bob => [Person: Bob Smith, 0]
sue => [Person: Sue Jones, 100000]
>>> 
>>> x.lastName()
'Smith'
>>> x.name
'Bob Smith'
>>> ================================ RESTART ================================
>>> 
tom = [Person: Tom Jones, 50000]
bob = [Person: Bob Smith, 0]
sue = [Person: Sue Jones, 100000]
>>> ================================ RESTART ================================
>>> 
tom = [Person: Tom Jones, 50000]
bob = [Person: Bob Smith, 0]
sue = [Person: Sue Jones, 110000.0]
>>> ================================ RESTART ================================
>>> 
tom = [Person: Tom Jones, 50000]
bob = [Person: Bob Smith, 0]
sue = [Person: Sue Jones, 121000.0]
>>> ================================ RESTART ================================
>>> 
tom = [Person: Tom Jones, 50000]
bob = [Person: Bob Smith, 0]
sue = [Person: Sue Jones, 133100.0]
>>> ================================ RESTART ================================
>>> 
tom = [Person: Tom Jones, 50000]
bob = [Person: Bob Smith, 0]
sue = [Person: Sue Jones, 146410.0]
>>> ================================ RESTART ================================
>>> 
tom = [Person: Tom Jones, 50000]
bob = [Person: Bob Smith, 0]
sue = [Person: Sue Jones, 161051.0]
>>> ================================ RESTART ================================
>>> 
tom = [Person: Tom Jones, 50000]
bob = [Person: Bob Smith, 0]
sue = [Person: Sue Jones, 177156.1]
>>> tom = [Person: Tom Jones, 50000]
bob = [Person: Bob Smith, 0]
sue = [Person: Sue Jones, 100000]
SyntaxError: invalid syntax
>>> 
>>> 
>>> dir('')
['__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']
>>> 
>>> import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
>>> 
[DEBUG ON]
>>> ================================ RESTART ================================
[DEBUG ON]
>>> 
141246703213942603683520966701614733366889617518454111681368808585711816984270751255808912631671152637335603208431366082764203838069979338335971185726639923431051777851865399011877999645131707069373498212631323752553111215372844035950900535954860733418453405575566736801565587405464699640499050849699472357900905617571376618228216434213181520991556677126498651782204174061830939239176861341383294018240225838692725596147005144243281075275629495339093813198966735633606329691023842454125835888656873133981287240980008838073668221804264432910894030789020219440578198488267339768238872279902157420307247570510423845868872596735891805818727796435753018518086641356012851302546726823009250218328018251907340245449863183265637987862198511046362985461949587281119139907228004385942880953958816554567625296086916885774828934449941362416588675326940332561103664556982622206834474219811081872404929503481991376740379825998791411879802717583885498575115299471743469241117070230398103378615232793710290992656444842895511830355733152020804157920090041811951880456705515468349446182731742327685989277607620709525878318766488368348965015474997864119765441433356928012344111765735336393557879214937004347568208665958717764059293592887514292843557047089164876483116615691886203812997555690171892169733755224469032475078797830901321579940127337210694377283439922280274060798234786740434893458120198341101033812506720046609891160700284002100980452964039788704335302619337597862052192280371481132164147186514169090917191909376
[DEBUG ON]
>>> 
[DEBUG OFF]
>>> 
>>> 
