1. naming
    1. underscore/letter, then letters, digits or underscores
    2. case-sensitive
    3. reserved words/keywords
      1. Subtopic
        1. Subtopic
  2. description
    1. An interpreted, bytecode compiled language. The bytecode is cached. It features dynamic typing and optional object orientation.
  3. running
    1. an interactive shell
      1. Subtopic
      2. To return to the outermost block, hit the carriage return on a blank line.
      3. expressions are automatically echoed to the console
        1. example
          1. Subtopic
    2. from scripts
      1. stored in .py files
      2. expressions are not automatically printed to standard output
  4. blocks
    1. determined by indentation
      1. example
        1. Subtopic
  5. statements
    1. no termination character
  6. comments
    1. begin with "#"
  7. operators
    1. assignment
      1. Subtopic
        1. multiples allowed
          1. Subtopic
          2. Subtopic
      2. compound assignment
        1. Subtopic
          1. works on many datatypes, including Strings
        2. -=
      3. creates references
      4. names created when first assigned
    2. equality
      1. ==
    3. modulo
      1. %
      2. used to inject values into strings
        1. Subtopic
        2. with a tuple:
          1. "One: %s Two: %s" % (1, 2)
        3. with a dictionary:
          1. "One: %(two)s Two: %(one)s" % {'one': "1", "two": 2}
    4. mathematical
  8. native data types
    1. Integers
    2. Floats
    3. strings
      1. delimiting
        1. delimited by "xxxxx" or 'xxxxx'
          1. use for including quotes in strings, e.g: 'The word "no" is small.'
        2. multiline: delimit with triple quotes: ''' or """
        3. Subtopic
          1. example
          2. \"
          3. backslash must be escaped with a backslash
          4. \\
      2. concatenation
        1. use + operator
          1. example
          2. Subtopic
      3. splitting
        1. Subtopic
      4. repetition
        1. use the * operator
          1. example
          2. Subtopic
      5. formatting
        1. characters available
          1. example
          2. 'Her name is %s.' % her_name
          3. see documentation for list: http://www.python.org/doc/current/lib/typesseq-strings.html
          4. can even use dictionaries
          5. 'The value is %(key)s' % my_dictionary
        2. flags available
          1. see: http://www.python.org/doc/current/lib/typesseq-strings.html
      6. can be treated as an array
        1. my_string[5]
      7. can be iterated over
        1. for each_character in my_string:
      8. get length
        1. Subtopic
    4. containers
      1. act like Vectors, in that you can mix datatypes
      2. sequences
        1. lists
          1. one-dimensional dynamic arrays
          2. mutable: add and delete items after creation
          3. Elements can be complex data types.
          4. defined with brackets
          5. Subtopic
          6. zero-based indicies
          7. negative numbers can be used to indicate elements from end of array, with -1 being the last element
          8. slices, array ranges, via [x:y]
          9. non-inclusive for second parameter: array[:2] does not include my_array(2)
          10. omit first or last value in range to start from beginning/end
          11. appending
          12. Subtopic
          13. example
          14. Subtopic
          15. Subtopic
          16. example
          17. Subtopic
          18. Subtopic
          19. example
          20. Subtopic
        2. tuples
          1. act like lists
          2. immutable
          3. once created, the elements cannot be changed
      3. dictionaries
        1. associative arrays
        2. hash tables
        3. declaring
          1. curly parenthesis
          2. Subtopic
          3. Subtopic
          4. The value can be a complex data structure.
          5. dict()
          6. dict can be subclassed
        4. accessing values
          1. Subtopic
        5. can use function labels
          1. Subtopic
        6. iteration
          1. over keys
          2. Subtopic
          3. over values
          4. Subtopic
        7. add pairs dynamically
        8. test for existence of keys
          1. returns true if key exists
          2. Subtopic
          3. if 'key_in_question' in my_dictionary
      4. sets
        1. built-in for version 2.5 and later
    5. casting
      1. int(<string>)
        1. convert a string to an integer
      2. str(<integer>)
        1. convert an integer to a string
  9. flow control
    1. conditional execution
      1. truth testing
        1. true
          1. non-zero number or non-empty object
        2. false
          1. zero or empty object
        3. comparison and equality tests return 0 or 1
      2. Subtopic
        1. example
          1. Subtopic
      3. Subtopic
    2. repetition
      1. Subtopic
        1. interates through the elements in a collection
          1. example
          2. Subtopic
          3. use range() for a counting loop
          4. Subtopic
          5. Subtopic
      2. Subtopic
        1. Subtopic
    3. jump to next iteration
      1. Subtopic
        1. Subtopic
    4. break out of a loop
      1. Subtopic
        1. Subtopic
    5. do nothing, statement placeholder
      1. Subtopic
  10. functions
    1. Subtopic
      1. creates a function object
        1. assignment is allowed
          1. Subtopic
          2. so, don't call a function without parenthesis
    2. support for optional arguments
      1. must come after mandatory arguments
      2. form of optional (default) arguments
        1. x=<default value>
      3. example
        1. def function_with_optional( required_parameter, optional_parameter=2 )
    3. argument lists
      1. Subtopic
      2. keyword argument lists
        1. Subtopic
          1. the keyword argument list is a dictionary
    4. Subtopic
      1. but immutable types are discarded and reassigned
    5. call with parenthesis notation
    6. supports lambda functions
      1. example
        1. Subtopic
          1. creates an anonymouns function with the name of "anonymous_function"
    7. returning values
      1. Subtopic
      2. can return a tuple
        1. multiple values are returned with tuple unpacking
    8. documentation
      1. can begin with a string defining the function
      2. getting help on methods
        1. in IPython, you can append a "?" to a method name to get more information
          1. example
          2. Subtopic
          3. output
          4. Subtopic
          5. Docstring is the documentation inside the program's code.
  11. classes & objects
    1. Subtopic
    2. scope
      1. private
        1. example
          1. Subtopic
      2. "protected"
        1. example
          1. _my_protected_variable
        2. just a convention, the member is accessible from outside the class
    3. methods
      1. Subtopic
      2. Subtopic
        1. Subtopic
        2. Subtopic
        3. Subtopic
      3. constructors
        1. Subtopic
          1. Subtopic
      4. built-in overloadable methods
        1. __call__(self, n)
          1. allows objects to be treated like function calls
          2. example
          3. Subtopic
        2. __del__(self)
          1. overload default destructor
        3. __len__(self)
          1. Subtopic
          2. example
          3. Subtopic
        4. __cmp__(self, n)
          1. comparison
      5. static
        1. Subtopic
        2. Subtopic
        3. example
          1. Subtopic
        4. Method can reference class variables by explicitly naming the class.
        5. Can be called with an instance or just the class.
      6. class
        1. Subtopic
        2. A reference to the class must be the first parameter in the method's definition.
          1. Subtopic
          2. Subtopic
        3. example
          1. Subtopic
        4. Subtopic
    4. subclassing
      1. limited multiple inheritance
      2. form
        1. single inheritance
          1. Subtopic
        2. multiple inheritance
          1. Subtopic
      3. Subtopic
        1. Subtopic
          1. bound method
      4. call parent's methods by explicitly calling the super class
        1. Subtopic
          1. Subtopic
      5. "new-style" classes
        1. Subtopic
    5. variables
      1. Variables defined in a class are class variables.
        1. example
          1. Subtopic
        2. Instances can override these class variables, creating local copies, but leaving the class variable unaffected.
      2. Subtopic
      3. properties
        1. requires that the class be a "new-style" class
          1. Topic
        2. Instance variables accessible through getter and setter functions
          1. when calling code gets the property, the getter method is called
          2. when calling code sets the property, the setter method is called
        3. Subtopic
          1. Subtopic
          2. example
          3. Subtopic
        4. delete()
        5. documentation attribute
    6. A string after the class declaration is documentation for the class
      1. example
        1. Subtopic
      2. Subtopic
    7. objects
      1. instantiation
        1. call the class
          1. example
          2. Subtopic
      2. comparing objects
        1. Subtopic
          1. true if the objects are equal in value
        2. Subtopic
          1. true if they point to the same object
      3. Subtopic
        1. if a class variable of the same name exists, the appendage will override the class variable
    8. Exceptions
      1. format
        1. Subtopic
      2. catching
        1. Subtopic
          1. except IOError:
        2. Subtopic
          1. except:
        3. except takes an optional object parameter
        4. To figure out what exception needs to be handled, run the offending code. When Python breaks, the error message will tell you the exception thrown.
        5. To catch multiple exceptions with one block of code, use a tuple.
          1. Subtopic
      3. raising
        1. Subtopic
        2. Subtopic
    9. documentation
      1. can begin with a string defining the class
      2. getting help on objects
        1. Subtopic
        2. Subtopic
          1. gives the names inside an object
          2. can be used on packages
          3. reflection
        3. dir()
          1. names of objects in current scope
        4. locals()
          1. Returns a dictionary of the current scope. Names are the keys, definitions are the values.
        5. Subtopic
        6. Subtopic
          1. get Python's internal identity for an object
          2. all objects have a unique number
  12. built-in fuctions
    1. Subtopic
      1. length of a list
    2. Subtopic
      1. appends newline
        1. examples
          1. Subtopic
    3. getting user input
      1. Subtopic
        1. get input from your user via a prompt
      2. raw_input(<optional prompt string>)
    4. converting data
      1. Subtopic
      2. Subtopic
        1. get a string representation
      3. Subtopic
      4. Subtopic
      5. Subtopic
      6. Subtopic
      7. Subtopic
        1. get the ASCII code of a character
      8. Subtopic
        1. string to float
      9. Subtopic
        1. string to integer
    5. extremes
      1. Subtopic
      2. Subtopic
    6. string manipulation
      1. Subtopic
      2. Subtopic
        1. first character of string
      3. Subtopic
      4. Subtopic
      5. Subtopic
      6. Subtopic
      7. Subtopic
        1. trailing/leading whitespace
    7. create an iterator for a collection
      1. Subtopic
      2. Subtopic
        1. Subtopic
  13. command-line applications
    1. list of calling parameters
      1. sys.argv
        1. example
          1. Subtopic
        2. parse into tuple
          1. getopt.getopt(sys.argv, <string of short, single letter, options>, <list of long options>)
    2. signal handling
      1. uses "signal" library
        1. to trap and handle a signal
          1. signal.signal(signal.<SIG constant>, <label_of_method you want to call>)
          2. example of handling CTL-C
          3. Subtopic
        2. Subtopic
          1. signal.signal(signal.<SIG constant>, signal.SIG_IGN)
      2. Linux signals
        1. Subtopic
          1. generate #14, SIGALRM
          2. signal.alarm(<number of seconds to wait before generating alarm>)
    3. make script files executable
      1. Linux
        1. add #!/usr/bin/env python to top of file
    4. if __name__ == '__main__':
  14. debugging & performance
    1. profiling
    2. logging
      1. system
        1. use 'syslog' module
          1. syslog( string )
    3. assert <test>[, string]
      1. use to force a traceback if the test fails
      2. example
        1. Subtopic
      3. does not evaluate if Python is run with -O or -OO
  15. libraries/modules
    1. importing
      1. import entire library
        1. format
          1. Subtopic
      2. import function from a library
        1. format
          1. Subtopic
      3. import library with an alias
        1. import a_module as another_name_for_module
          1. Subtopic
      4. importing forces Python to evaluate the imported code
        1. but only the first time it is imported into a program
      5. "imp" module
      6. Subtopic
    2. specific functionality
      1. regular expressions
        1. "re"
      2. plotting
        1. "Gnuplot"
      3. operating system functionality
        1. "os"
          1. getcwd()
          2. get current working directory
          3. listdir()
          4. list directory contents
          5. chown()
          6. chmod()
          7. rename()
          8. remove()
          9. mkdir()
          10. system()
          11. execute command
          12. environment variables
          13. os.environ
          14. dictionary
      4. numerical
        1. "NumPy"
      5. profiling
        1. "profile"
    3. create namespaces
    4. documenting
      1. can begin with a string describing the module
    5. make runnable, only if called from command line
      1. Subtopic
        1. Subtopic
        2. block will not run when imported
  16. packages
    1. collections of modules
    2. organized in directories
      1. Subtopic
        1. code in this file evaluated first time a module from the package is imported
    3. importing
      1. Subtopic
      2. Subtopic
        1. example
          1. import my_package.my_module
      3. Within a package, modules can import from the same packagewithout giving the path.
        1. assumes current path of module
      4. packages can be zipped
        1. use PyZipFile
        2. Subtopic
    4. repository for Python packages
      1. http://pypi.python.org/pypi
  17. bound/unbound
  18. scoping
    1. globals
      1. if you must use globals, be sure to declare them in your functions, or assignment will produce local variables
        1. syntax
          1. Subtopic
  19. I/O
    1. files
      1. simple
        1. opening
          1. Subtopic
        2. reading
          1. file_contents = file_handle.read()
          2. as a collection of lines
          3. file_handle.readlines()
          4. example
          5. Subtopic
          6. Subtopic
          7. Subtopic
        3. closing
          1. file_handle.close()
      2. sys.open()
        1. read( number_of_bytes_or_blank_for_entire_file )
        2. readline()
        3. readlines()
        4. write( string_to_write )
        5. writelines( list_of_strings_to_write )
        6. close()
      3. temporary
        1. use "tempfile" module
          1. mktemp()
          2. Subtopic
      4. a file in Python is an iterator over the lines of the file
        1. Subtopic
    2. pipes
      1. stdin
        1. sys.stdin
          1. read()
          2. readline()
          3. readlines()
      2. stdout
        1. sys.stdout
          1. write()
          2. Subtopic
          3. flush()
          4. Subtopic
      3. os.popen( command_as_string, r_or_w )
    3. exceptions
      1. IOError
  20. GUI development
    1. Tk
      1. Tkinter
        1. Pmw
          1. http://pmw.sourceforge.net/
    2. wxPython
      1. http://wxpython.org
  21. iterator protocol
  22. iterators
    1. definition
      1. an object implementing the iterator protocol
        1. iterator protocol requires implementation of two methods:
          1. next
          2. returns each item iterated over
          3. Subtopic
          4. __iter__
          5. returns the iterator
        2. Subtopic
          1. Subtopic
          2. no built-in way to rewind an iterator
          3. The developer of the class must add rewind functionality.
        3. example
          1. Subtopic
          2. Subtopic
          3. Subtopic
          4. you could add a method to rewind the class, or alter the sequence of delivery in any way
          5. Subtopic
    2. generating functions
      1. return iterators
      2. Subtopic
      3. simple example
        1. Subtopic
          1. Subtopic
          2. could also use a for loop to iterate over my_iterator
          3. Subtopic
    3. generator expression
      1. a shorthand for producing iterators
      2. example
        1. Subtopic
  23. list displays