Course Summary

Python Fundamentals is a 4-day training course in the Python language and its many applications. The course covers the language itself, explains object-oriented as well as functional programming techniques, error handling, packaging, system and network programming, many of the Python extensions (libraries), as well as best practices. All concepts are explained through hands-on examples and exercises, so students learn by coding in Python.

Duration

4 days.

Objectives

Upon completion of this course, you will be able to:
  • Develop complex programs in Python
  • Understand the best use-case applications for Python
  • Use Python's modules for text and XML processing, networking, system process control, database/LDAP/HTTP communication, etc.
  • Design your code in both object-oriented and procedural fashion using best practices
  • Handle errors in Python
  • Write lean Python code

Audience

This course is designed for programmers who need to develop software in Python as well as system administrators who wish to take advantage of Python's simple scripting abilities to automate back-end tasks.

Students should have some prior programming experience and be familiar with basic concepts such as variables/scopes, flow-control, functions, modularization, error handling, TCP/IP networking, and so forth.

Familiarity with object-oriented programming language (such as Java or C++) and/or scripting languages (such as Perl or Bash shell scripting) can be helpful.

Additional Notes

About Your Instructor

Marilyn Davis earned a Ph.D. in Radio Astronomy, and M.A. in Applied Physics, from UCSD; and a B.S. and M.S. in Mathematics from Denver University. Computer programming captured her imagination and she has made significant contributions in scientific, statistical, operations research, test-development and groupware applications. Teaching has always been a favorite activity. She has been teaching C Programming at UCSC-Extension for 15 years. When she met Python, for 5 years.

Marilyn specializes in Python training, she has taught Python for Google, Nokia, Cisco, VMware and more. Even the marketing department at Google took a class.

After teaching C for 14 years, Marilyn met Python and immediately recognized this new language as a big boon to software engineering. Engineers typically claim a 9-fold increase in productivity over C/C++ with significant improvements in readability and reliability.

Marilyn's Talk on Why Python

This text will be replaced

Marilyn's Google Tech Talk

Some Python Integrated Development Environments: Video of Marilyn Davis' discussion on Emacs at the Bay Area Python Interest Group.

About the Platform

This course can be taught on most major operating systems, which support Python, such as Windows, Linux, Mac OS X, etc.

Trademarks

"Python" is a registered trademark of the Python Software Foundation. All other marks are the properties of their respective owners.

Outline

Output

  • Executing a Python program
  • Syntax: code blocks, colons
  • if, elif and else
  • while and another else
  • Writing to stdout
  • Relational and logical operators

Input

  • Input from stdin
  • Factory functions
  • Catching an exception:
    • yet another else
  • Formatted strings
  • Integer division issue

for range

  • range operator
  • for loop
  • tuples

Functions

  • Function protocols
  • import and reload
  • Module: random
  • Introspection

Scope

  • Indentifier scope
  • Default arguments
  • Keyword arguments

Sequences

  • Sequence types: str, tuple, list
  • Sequence slicing and other manipulations

Important Trick

  • Module: sys
  • Important trick:
    • _name_and_'_main_'
  • Valid identifiers

Comprehensions

  • Scope issues
  • List comprehensions

Dictionaries

  • Importing with from
  • Dictionaries

File IO

  • File I/O
  • Module: os
  • Walking A Directory

Packages

  • Modules: shutil, tempfile
  • Python Packages
  • Debugging 

Dynamic Code

  • Dynamic Code Generation
  • Modules:
    • subprocess
    • glob
    • profile 

Function Fancies

  • Function protocols: variable length argument lists
  • Formatted printing using a dictionary for replacement
  • Unpacking sequences and dictionaries
  • Generators (Optional)
  • Decorators (Optional)

OOP

  • Module: shelve
  • Classes
  • Inheritance
  • Class variable

Overriding

  • Overriding
  • Has-A vs Is-A relationships

New Style Classes

  • Useful attributes
  • Iterators
  • New style classes
  • Attribute control (Optional)
  • property (Optional)
  • Static methods (Optional)
  • Class methods (Optional)
  • Diamond inheritance (Optional)

Developer Modules

  • Context Manager class
  • Module: unittest
  • Module: optparse

Wrap Up

  • Exceptions
  • Namespaces
  • Nests
  • Pitfalls
  • Finding Modules and Help

re Module

  • re - Regular Expressions
  • Search and replace
  • Named groups

re Syntax

  • Regular expression syntax
  • Testing regular expressions