A Python Book: Beginning Python, Advanced Python, And .

3y ago
282 Views
59 Downloads
1.30 MB
278 Pages
Last View : Today
Last Download : 3m ago
Upload by : Audrey Hope
Transcription

A Python BookA Python Book: Beginning Python, AdvancedPython, and Python ExercisesAuthor:Dave p://www.davekuhlman.orgPage 1

A Python BookRevision1.3aDateDecember 15, 2013CopyrightCopyright (c) 2009 Dave Kuhlman. All Rights Reserved. This document is subjectto the provisions of the Open Source MIT Licensehttp://www.opensource.org/licenses/mit license.php.AbstractThis document is a self learning document for a course in Python programming.This course contains (1) a part for beginners, (2) a discussion of several advancedtopics that are of interest to Python programmers, and (3) a Python workbook withlots of exercises.Page 2

A Python BookContents1 Part 1 Beginning Python.101.1 Introductions Etc.101.1.1 Resources.111.1.2 A general description of Python.121.1.3 Interactive Python.151.2 Lexical matters.151.2.1 Lines.151.2.2 Comments.161.2.3 Names and tokens.161.2.4 Blocks and indentation.161.2.5 Doc strings.171.2.6 Program structure.171.2.7 Operators.181.2.8 Also see.191.2.9 Code evaluation.191.3 Statements and inspection preliminaries.201.4 Built in data types.211.4.1 Numeric types.211.4.2 Tuples and lists.211.4.3 Strings.241.4.3.1 The new string.format method.261.4.3.2 Unicode strings.271.4.4 Dictionaries.291.4.5 Files.321.4.6 Other built in types.351.4.6.1 The None value/type.351.4.6.2 Boolean values.361.4.6.3 Sets and frozensets.361.5 Functions and Classes A Preview.361.6 Statements.371.6.1 Assignment statement.371.6.2 import statement.391.6.3 print statement.411.6.4 if: elif: else: statement.431.6.5 for: statement.441.6.6 while: statement.48Page 3

A Python Book1.6.7 continue and break statements.481.6.8 try: except: statement.491.6.9 raise statement.511.6.10 with: statement.521.6.10.1 Writing a context manager.521.6.10.2 Using the with: statement.531.6.11 del.541.6.12 case statement.551.7 Functions, Modules, Packages, and Debugging.551.7.1 Functions.551.7.1.1 The def statement.551.7.1.2 Returning values.551.7.1.3 Parameters.561.7.1.4 Arguments.561.7.1.5 Local variables.571.7.1.6 Other things to know about functions.571.7.1.7 Global variables and the global statement.581.7.1.8 Doc strings for functions.601.7.1.9 Decorators for functions.601.7.2 lambda.611.7.3 Iterators and generators.621.7.4 Modules.671.7.4.1 Doc strings for modules.681.7.5 Packages.681.8 Classes.691.8.1 A simple class.691.8.2 Defining methods.701.8.3 The constructor.701.8.4 Member variables.701.8.5 Calling methods.711.8.6 Adding inheritance.711.8.7 Class variables.721.8.8 Class methods and static methods.721.8.9 Properties.741.8.10 Interfaces.751.8.11 New style classes.751.8.12 Doc strings for classes.771.8.13 Private members.771.9 Special Tasks.771.9.1 Debugging tools.77Page 4

A Python Book1.9.2 File input and output.781.9.3 Unit tests.801.9.3.1 A simple example.801.9.3.2 Unit test suites.811.9.3.3 Additional unittest features.831.9.3.4 Guidance on Unit Testing.851.9.4 doctest.851.9.5 The Python database API.871.9.6 Installing Python packages.881.10 More Python Features and Exercises.892 Part 2 Advanced Python.902.1 Introduction Python 201 (Slightly) Advanced Python Topics.902.2 Regular Expressions.902.2.1 Defining regular expressions.902.2.2 Compiling regular expressions.912.2.3 Using regular expressions.912.2.4 Using match objects to extract a value.922.2.5 Extracting multiple items.932.2.6 Replacing multiple items.942.3 Iterator Objects.962.3.1 Example A generator function.982.3.2 Example A class containing a generator method.1002.3.3 Example An iterator class.1022.3.4 Example An iterator class that uses yield.1042.3.5 Example A list comprehension.1052.3.6 Example A generator expression.1052.4 Unit Tests.1062.4.1 Defining unit tests.1062.4.1.1 Create a test class.1062.5 Extending and embedding Python.1092.5.1 Introduction and concepts.1092.5.2 Extension modules.1102.5.3 SWIG.1122.5.4 Pyrex.1152.5.5 SWIG vs. Pyrex.1202.5.6 Cython.1202.5.7 Extension types.1222.5.8 Extension classes.1222.6 Parsing.1222.6.1 Special purpose parsers.123Page 5

A Python Book2.6.2 Writing a

A Python Book A Python Book: Beginning Python, Advanced Python, and Python Exercises Author: Dave Kuhlman Contact: dkuhlman@davekuhlman.org

Related Documents:

Python Programming for the Absolute Beginner Second Edition. CONTENTS CHAPTER 1 GETTING STARTED: THE GAME OVER PROGRAM 1 Examining the Game Over Program 2 Introducing Python 3 Python Is Easy to Use 3 Python Is Powerful 3 Python Is Object Oriented 4 Python Is a "Glue" Language 4 Python Runs Everywhere 4 Python Has a Strong Community 4 Python Is Free and Open Source 5 Setting Up Python on .

Python 2 versus Python 3 - the great debate Installing Python Setting up the Python interpreter About virtualenv Your first virtual environment Your friend, the console How you can run a Python program Running Python scripts Running the Python interactive shell Running Python as a service Running Python as a GUI application How is Python code .

Python is readable 5 Python is complete—"batteries included" 6 Python is cross-platform 6 Python is free 6 1.3 What Python doesn't do as well 7 Python is not the fastest language 7 Python doesn't have the most libraries 8 Python doesn't check variable types at compile time 8 1.4 Why learn Python 3? 8 1.5 Summary 9

site "Python 2.x is legacy, Python 3.x is the present and future of the language". In addition, "Python 3 eliminates many quirks that can unnecessarily trip up beginning programmers". However, note that Python 2 is currently still rather widely used. Python 2 and 3 are about 90% similar. Hence if you learn Python 3, you will likely

There are currently two versions of Python in use; Python 2 and Python 3. Python 3 is not backward compatible with Python 2. A lot of the imported modules were only available in Python 2 for quite some time, leading to a slow adoption of Python 3. However, this not really an issue anymore. Support for Python 2 will end in 2020.

Python site "Python 2.x is legacy, Python 3.x is the present and future of the language". In addition, "Python 3 eliminates many quirks that can unnecessarily trip up beginning programmers". However, note that Python 2 is currently still rather widely used. Python 2 and 3 are about 90% similar. Hence if you learn Python 3, you will likely

Mike Driscoll has been programming with Python for more than a decade. He has been writing about Python on his blog, The Mouse vs. The Python, for many years. Mike is the author of several Python books including Python 101, Python Interviews, and ReportLab: PDF Processing with Python. You can find Mike on Twitter or GitHub via his handle .

additif a en fait des effets secondaires nocifs pour notre santé. De plus, ce n’est pas parce qu’un additif est d’origine naturelle qu’il est forcément sans danger. Car si l’on prend l’exemple d’un champignon ou d’une plante toxique pour l’homme, bien qu’ils soient naturels, ils ne sont pas sans effets secondaires.