python 45 minutes hangout #3
TRANSCRIPT
Last Hangout
❖ Data types and containers
❖ Functions
❖ Exceptions
❖ Namespaces and modules
❖ Re-read the sorted list example.
In This Hangout
❖ Working with files
❖ Reading options passed to your program
❖ Functional programming
❖ Advanced iteration
❖ Debugging tools
Working With Files
❖ What’s simpler than open(“path/to/file”) ?
❖ Don’t forget to close the file (finally:)
❖ And even cleaner way use managed context (with:)
❖ File-like objects.
Reading Options
❖ from optparse import OptionParser
❖ Adding options (short and long), setting default values and errors
❖ using __main__ the entry point.
Functional Programing
❖ Python is a multi-paradigm language (What does that mean?)
❖ Functions are objects and they are first class variables.
❖ Higher order functions
❖ Remember the first hangout example ?
Functional Programing (2)
❖ Anonymous functions (lambda)
❖ Nested functions (function that defines function)
❖ Closures and “Lexical Scoping” issue.
❖ Operators as functions
❖ Trying doctest.
❖ Decorators and (@notation).
Advanced Iteration
❖ List comprehension
❖ Generator expressions
❖ Understanding yield
❖ itertools
❖ zip and izip