python 45 minutes hangout #3

14
Python 45 Minutes By @AlSayed Gamal

Upload: al-sayed-gamal

Post on 13-Jul-2015

525 views

Category:

Education


1 download

TRANSCRIPT

Python45

MinutesBy @AlSayed Gamal

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

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 CL Options

Reading Options

❖ from optparse import OptionParser

❖ Adding options (short and long), setting default values and errors

❖ using __main__ the entry point.

Functional Programming

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

Advanced Iteration

❖ List comprehension

❖ Generator expressions

❖ Understanding yield

❖ itertools

❖ zip and izip

Questions?

Thank you :)@AlSayed Gamal