Python 2 Programming

מק"ט: #40830 | משך קורס: 32 שעות אק'
| מספר מפגשים: 4

This is a technical course that introduces the Python 2 programming language. It is an instructor led presentation and hands on exercises course using MS Windows, but is equally applicable to other platforms such as Linux.

לפרטים נוספים, מלא את פרטיך או התקשר 03-7100673
*שדות חובה
PDF version

מטרות

  • Use the Python interactive interpreter to write and run Python 2 programs
  • Understand Python 2 language elements
  • Exploit the rich library of Python libraries and modules
  • Recognize simple and complex variable types and select appropriately
  • Use Python 2 operators and built-in functions
  • Understand procedural control flow in Python 2
  • Program file input/output, including persistent data objects.
  • Create well organized and efficient code using functions and modules
  • Use Object Oriented programming techniques in Python 2.
  • Build robust applications with error trapping and reporting
  • Run and control other programs from Python
  • Take advantage of multi-core processors with multiprocessing
     

קהל יעד

This course is suitable for programmers maintaining existing projects or starting new projects in Python 2.

תנאי קדם

  • No previous knowledge of Python is assumed, although delegates should be familiar with at least one programming language.
  • Experience of another scripting language, such as Perl or PHP, will be an advantage, as will previous experience of object oriented programming.

נושאים

Chapter 1: Introduction to Python

  • What is Python 2?
  • Why Python?
  • Performance downsides
  • The community
  • Running Python interactively
  • Python scripts
  • Python help
  • Anatomy of a Python script
  • Modules
  • Functions and built-ins

 

Chapter 2: Fundamental Variables

  • Python is Object Oriented
  • Python variables
  • Variable names
  • Type specific methods
  • Operators and type
  • Augmented assignments
  • Python types
  • Numeric types
  • Switching types
  • Python lists introduced
  • Python tuples introduced
  • Python dictionaries introduced

 

Chapter 3: Flow Control

  • Python conditionals
  • Indentation
  • What is truth?
  • Boolean and logical operators
  • Chained comparisons
  • Sequence and collection tests
  • Object types
  • A note on Exception Handling
  • While loops
  • Loop control statements
  • For loops
  • enumerate
  • Counting ‘for’ loops
  • Zipping through multiple lists
  • Conditional expressions
  • Unconditional flow control


Chapter 4: String Handling

  • The print function
  • Cooking strings
  • String concatenation
  • “Quotes”
  • String methods
  • String tests
  • String formatting
  • Other string formatting aids
  • Slicing a string
  • String methods – split and join

 

Chapter 5: Collections

  • Python types – reminder
  • Useful tuple operations
  • Python lists
  • Tuple & list slicing
  • Adding items to a list
  • Removing items by position
  • Removing list items by content
  • Sorting
  • Miscellaneous list methods
  • List methods
  • Sets
  • Exploiting sets
  • Set operators
  • Python dictionaries
  • Dictionary values
  • Removing items from a dictionary
  • Dictionary methods

 

Chapter 6: Regular Expressions

  • Python regular expressions
  • Elementary extended RE meta-characters
  • Regular expression objects
  • Regular expression substitution
  • Regular expression split
  • Matching alternatives
  • Anchors
  • Class shortcuts
  • Flags
  • Repeat quantifiers
  • Quantifiers
  • Back-references
  • Global matches


Chapter 7: Data Storage and File Handling

  • New file objects
  • Reading files into Python
  • Reading tricks
  • Filter programs – fileinput module
  • Writing to files from Python
  • Standard streams
  • More tricks
  • Random access
  • Python Pickle Persistence
  • Pickle Protocols
  • Build some shelves
  • Compression
  • Database interface overview

 

Chapter 8: Functions

  • Python functions
  • Function parameters
  • Assigning default values to parameters
  • Variadic functions
  • Keyword parameters
  • Returning objects from a function
  • Variables in functions
  • Nested functions
  • Function documentation
  • Lamdba functions
  • Lambda as a sort key
  • Lambda in re.sub

 

Chapter 9: Advanced Collections

  • Advanced list functions – filter and map
  • List comprehensions
  • Lazy lists
  • Generators
  • Generator objects and next – coroutines
  • List comprehensions as generators
  • Copying collections – problem
  • Copying collections – slice solution?
  • Copying collections – deepcopy solution

 

Chapter 10: Modules and Packages

  • What are modules?
  • What are packages?
  • Multiple source files
  • How does Python find a module?
  • Importing a module
  • Importing names
  • Directories as packages
  • Writing a module
  • Module documentation
  • Testing a module
  • Python debugger
  • Python profiler

 

Chapter 11: Classes and OOP

  • Object-Oriented Programming
  • Using objects
  • A simple class
  • Defining classes
  • Defining methods
  • Constructing an object
  • Special methods
  • Operator overload special methods
  • Inheritance
  • Inheritance terminology
  • New-style classes
  • Properties and decorators
  • Class methods

 

Chapter 12: Error Handling and Exceptions

  • Writing to stderr
  • Controlling warnings
  • Exception handling
  • Exception syntax
  • Multiple exceptions
  • Exception arguments
  • The finally block
  • Order of execution
  • The Python exception hierarchy
  • A common mistake
  • The raise statement
  • Raising our own Exceptions
  • assert


Chapter 13: Multitasking

  • Family life
  • Creating a process from Python
  • Old interface examples
  • Waiting for a child
  • Using the subprocess module
  • The subprocess.Popen class
  • Running a basic process
  • Capturing the output
  • Passing data through a pipe
  • Processes and threads
  • Very basic threads in Python
  • Synchronisation objects in threading
  • Simple use of Lock
  • The trouble with threads
  • Using the multiprocessing module
  • Queue objects

 

Chapter 14: The Python Standard Library

  • The Standard Library
  • Home many modules have we seen so far?
  • Pretty Printer
  • Operating System interfaces – os and friends
  • System specific attributes – sys
  • Signal handling – signal
  • Converting a signal to an exception
  • Configuration files
  • The ConfigParser module
  • The datetime module and friends
  • The platform module
  • External function interface – ctypes
  • The socket module
  • __future__
  • Other modules
תגיות