Advanced Guide to Python 3 Programming
Advanced Guide to Python 3 Programming delves deeply into a host of subjects that you need to understand if you are to develop sophisticated real-world programs. Each topic is preceded by an introduction followed by more advanced topics, along with numerous examples, that take you to an advanced lev...
Saved in:
| Main Author | |
|---|---|
| Format | eBook |
| Language | English |
| Published |
Netherlands
Springer Nature
2019
Springer International Publishing AG Springer |
| Edition | 1 |
| Series | Undergraduate Topics in Computer Science |
| Subjects | |
| Online Access | Get full text |
| ISBN | 9783030259433 3030259439 9783030259426 3030259420 |
| DOI | 10.1007/978-3-031-40336-1 |
Cover
Table of Contents:
- 25.2.5 Obtaining Information About the Results
- 21 Working with Excel Files -- 21.1 Introduction -- 21.2 Excel Files -- 21.3 The Openpyxl. Workbook Class -- 21.4 The Openpyxl. WorkSheet Objects -- 21.5 Working with Cells -- 21.6 Sample Excel File Creation Application -- 21.7 Loading a Workbook from an Excel File -- 21.8 Online Resources -- 21.9 Exercises -- 22 Regular Expressions in Python -- 22.1 Introduction -- 22.2 What Are Regular Expressions? -- 22.3 Regular Expression Patterns -- 22.3.1 Pattern Metacharacters -- 22.3.2 Special Sequences -- 22.3.3 Sets -- 22.4 The Python re Module -- 22.5 Working with Python Regular Expressions -- 22.5.1 Using Raw Strings -- 22.5.2 Simple Example -- 22.5.3 The Match Object -- 22.5.4 The search() Function -- 22.5.5 The match() Function -- 22.5.6 The Difference Between Matching and Searching -- 22.5.7 The findall() Function -- 22.5.8 The finditer() Function -- 22.5.9 The split() Function -- 22.5.10 The sub() Function -- 22.5.11 The compile() Function -- 22.6 Online Resources -- 22.7 Exercises -- Database Access -- 23 Introduction to Databases -- 23.1 Introduction -- 23.2 What Is a Database? -- 23.2.1 Data Relationships -- 23.2.2 The Database Schema -- 23.3 SQL and Databases -- 23.4 Data Manipulation Language -- 23.5 Transactions in Databases -- 23.6 Further Reading -- 24 Python DB-API -- 24.1 Accessing a Database from Python -- 24.2 The DB-API -- 24.2.1 The Connect Function -- 24.2.2 The Connection Object -- 24.2.3 The Cursor Object -- 24.2.4 Mappings from Database Types to Python Types -- 24.2.5 Generating Errors -- 24.2.6 Row Descriptions -- 24.3 Transactions in PyMySQL -- 24.4 Online Resources -- 25 PyMySQL Module -- 25.1 The PyMySQL Module -- 25.2 Working with the PyMySQL Module -- 25.2.1 Importing the Module -- 25.2.2 Connect to the Database -- 25.2.3 Obtaining the Cursor Object -- 25.2.4 Using the Cursor Object
- 11.5 Online Resources -- 12 Building Games with pygame -- 12.1 Introduction -- 12.2 The Display Surface -- 12.3 Events -- 12.3.1 Event Types -- 12.3.2 Event Information -- 12.3.3 The Event Queue -- 12.4 A First pygame Application -- 12.5 Further Concepts -- 12.6 A More Interactive pygame Application -- 12.7 Alternative Approach to Processing Input Devices -- 12.8 pygame Modules -- 12.9 Online Resources -- 13 StarshipMeteors pygame -- 13.1 Creating a Spaceship Game -- 13.2 The Main Game Class -- 13.3 The GameObject Class -- 13.4 Displaying the Starship -- 13.5 Moving the Spaceship -- 13.6 Adding a Meteor Class -- 13.7 Moving the Meteors -- 13.8 Identifying a Collision -- 13.9 Identifying a Win -- 13.10 Increasing the Number of Meteors -- 13.11 Pausing the Game -- 13.12 Displaying the Game Over Message -- 13.13 The StarshipMeteors Game -- 13.14 Online Resources -- 13.15 Exercises -- Testing -- 14 Introduction to Testing -- 14.1 Introduction -- 14.2 Types of Testing -- 14.3 What Should Be Tested? -- 14.4 Testing Software Systems -- 14.4.1 Unit Testing -- 14.4.2 Integration Testing -- 14.4.3 System Testing -- 14.4.4 Installation/Upgrade Testing -- 14.4.5 Smoke Tests -- 14.5 Automating Testing -- 14.6 Test Driven Development -- 14.6.1 The TDD Cycle -- 14.6.2 Test Complexity -- 14.6.3 Refactoring -- 14.7 Design for Testability -- 14.7.1 Testability Rules of Thumb -- 14.8 Online Resources -- 14.9 Book Resources -- 15 PyTest Testing Framework -- 15.1 Introduction -- 15.2 What Is PyTest? -- 15.3 Setting Up PyTest -- 15.4 A Simple PyTest Example -- 15.5 Working with PyTest -- 15.6 Parameterised Tests -- 15.7 Online Resources -- 15.8 Exercises -- 16 Mocking for Testing -- 16.1 Introduction -- 16.2 Why Mock? -- 16.3 What Is Mocking? -- 16.4 Common Mocking Framework Concepts -- 16.5 Mocking Frameworks for Python -- 16.6 The unittest.mock Library
- 16.6.1 Mock and Magic Mock Classes -- 16.6.2 The Patchers -- 16.6.3 Mocking Returned Objects -- 16.6.4 Validating Mocks Have Been Called -- 16.7 Mock and MagicMock Usage -- 16.7.1 Naming Your Mocks -- 16.7.2 Mock Classes -- 16.7.3 Attributes on Mock Classes -- 16.7.4 Mocking Constants -- 16.7.5 Mocking Properties -- 16.7.6 Raising Exceptions with Mocks -- 16.7.7 Applying Patch to Every Test Method -- 16.7.8 Using Patch as a Context Manager -- 16.8 Mock Where You Use It -- 16.9 Patch Order Issues -- 16.10 How Many Mocks? -- 16.11 Mocking Considerations -- 16.12 Online Resources -- 16.13 Exercises -- File Input/Output -- 17 Introduction to Files, Paths and IO -- 17.1 Introduction -- 17.2 File Attributes -- 17.3 Paths -- 17.4 File Input/Output -- 17.5 Sequential Access Versus Random Access -- 17.6 Files and I/O in Python -- 17.7 Online Resources -- 18 Reading and Writing Files -- 18.1 Introduction -- 18.2 Obtaining References to Files -- 18.3 Reading Files -- 18.4 File Contents Iteration -- 18.5 Writing Data to Files -- 18.6 Using Files and with Statements -- 18.7 The Fileinput Module -- 18.8 Renaming Files -- 18.9 Deleting Files -- 18.10 Random Access Files -- 18.11 Directories -- 18.12 Temporary Files -- 18.13 Working with Paths -- 18.14 Online Resources -- 18.15 Exercise -- 19 Stream IO -- 19.1 Introduction -- 19.2 What is a Stream? -- 19.3 Python Streams -- 19.4 IOBase -- 19.5 Raw IO/UnBuffered IO Classes -- 19.6 Binary IO/Buffered IO Classes -- 19.7 Text Stream Classes -- 19.8 Stream Properties -- 19.9 Closing Streams -- 19.10 Returning to the open() Function -- 19.11 Online Resources -- 19.12 Exercise -- 20 Working with CSV Files -- 20.1 Introduction -- 20.2 CSV Files -- 20.2.1 The CSV Writer Class -- 20.2.2 The CSV Reader Class -- 20.2.3 The CSV DictWriter Class -- 20.2.4 The CSV DictReader Class -- 20.3 Online Resources -- 20.4 Exercises
- Intro -- Preface -- Chapter Organisation -- What You Need -- Python Versions -- Useful Python Resources -- Conventions -- Example Code and Sample Solutions -- Contents -- 1 Introduction -- 1.1 Introduction -- Computer Graphics -- 2 Introduction to Computer Graphics -- 2.1 Introduction -- 2.2 Background -- 2.3 The Graphical Computer Era -- 2.4 Interactive and Non Interactive Graphics -- 2.5 Pixels -- 2.6 Bit Map Versus Vector Graphics -- 2.7 Buffering -- 2.8 Python and Computer Graphics -- 2.9 References -- 2.10 Online Resources -- 3 Python Turtle Graphics -- 3.1 Introduction -- 3.2 The Turtle Graphics Library -- 3.2.1 The Turtle Module -- 3.2.2 Basic Turtle Graphics -- 3.2.3 Drawing Shapes -- 3.2.4 Filling Shapes -- 3.3 Other Graphics Libraries -- 3.4 3D Graphics -- 3.4.1 PyOpenGL -- 3.5 Online Resources -- 3.6 Exercises -- 4 Computer Generated Art -- 4.1 Creating Computer Art -- 4.2 A Computer Art Generator -- 4.3 Fractals in Python -- 4.3.1 The Koch Snowflake -- 4.3.2 Mandelbrot Set -- 4.4 Online Resources -- 4.5 Exercises -- 5 Introduction to Matplotlib -- 5.1 Introduction -- 5.2 Matplotlib -- 5.3 Plot Components -- 5.4 Matplotlib Architecture -- 5.4.1 Backend Layer -- 5.4.2 The Artist Layer -- 5.4.3 The Scripting Layer -- 5.5 Online Resources -- 6 Graphing with Matplotlib pyplot -- 6.1 Introduction -- 6.2 The pyplot API -- 6.3 Line Graphs -- 6.3.1 Coded Format Strings -- 6.4 Scatter Graph -- 6.4.1 When to Use Scatter Graphs -- 6.5 Pie Charts -- 6.5.1 Expanding Segments -- 6.5.2 When to Use Pie Charts -- 6.6 Bar Charts -- 6.6.1 Horizontal Bar Charts -- 6.6.2 Coloured Bars -- 6.6.3 Stacked Bar Charts -- 6.6.4 Grouped Bar Charts -- 6.7 Figures and Subplots -- 6.8 3D Graphs -- 6.9 Exercises -- 7 Graphical User Interfaces -- 7.1 Introduction -- 7.2 GUIs and WIMPS -- 7.3 Windowing Frameworks for Python -- 7.3.1 Platform-Independent GUI Libraries
- 7.3.2 Platform-Specific GUI Libraries -- 7.4 Online Resources -- 8 The wxPython GUI Library -- 8.1 The wxPython Library -- 8.1.1 wxPython Modules -- 8.1.2 Windows as Objects -- 8.1.3 A Simple Example -- 8.2 The wx.App Class -- 8.3 Window Classes -- 8.4 Widget/Control Classes -- 8.5 Dialogs -- 8.6 Arranging Widgets Within a Container -- 8.7 Drawing Graphics -- 8.8 Online Resources -- 8.9 Exercises -- 8.9.1 Simple GUI Application -- 9 Events in wxPython User Interfaces -- 9.1 Event Handling -- 9.2 Event Definitions -- 9.3 Types of Events -- 9.4 Binding an Event to an Event Handler -- 9.5 Implementing Event Handling -- 9.6 An Interactive wxPython GUI -- 9.7 Online Resources -- 9.8 Exercises -- 9.8.1 Simple GUI Application -- 9.8.2 GUI Interface to a Tic Tac Toe Game -- 10 PyDraw wxPython Example Application -- 10.1 Introduction -- 10.2 The PyDraw Application -- 10.3 The Structure of the Application -- 10.3.1 Model, View and Controller Architecture -- 10.3.2 PyDraw MVC Architecture -- 10.3.3 Additional Classes -- 10.3.4 Object Relationships -- 10.4 The Interactions Between Objects -- 10.4.1 The PyDrawApp -- 10.4.2 The PyDrawFrame Constructor -- 10.4.3 Changing the Application Mode -- 10.4.4 Adding a Graphic Object -- 10.5 The Classes -- 10.5.1 The PyDrawConstants Class -- 10.5.2 The PyDrawFrame Class -- 10.5.3 The PyDrawMenuBar Class -- 10.5.4 The PyDrawToolBar Class -- 10.5.5 The PyDrawController Class -- 10.5.6 The DrawingModel Class -- 10.5.7 The DrawingPanel Class -- 10.5.8 The DrawingController Class -- 10.5.9 The Figure Class -- 10.5.10 The Square Class -- 10.5.11 The Circle Class -- 10.5.12 The Line Class -- 10.5.13 The Text Class -- 10.6 References -- 10.7 Exercises -- Computer Games -- 11 Introduction to Games Programming -- 11.1 Introduction -- 11.2 Games Frameworks and Libraries -- 11.3 Python Games Development -- 11.4 Using Pygame