Details

Python Projects


Python Projects


1. Aufl.

von: Laura Cassell, Alan Gauld

30,99 €

Verlag: Wiley
Format: PDF
Veröffentl.: 24.11.2014
ISBN/EAN: 9781118908891
Sprache: englisch
Anzahl Seiten: 384

DRM-geschütztes eBook, Sie benötigen z.B. Adobe Digital Editions und eine Adobe ID zum Lesen.

Beschreibungen

<b>A guide to completing Python projects for those ready to take their skills to the next level</b><br /><br /><i>Python Projects</i> is the ultimate resource for the Python programmer with basic skills who is ready to move beyond tutorials and start building projects.<br /><br />The preeminent guide to bridge the gap between learning and doing, this book walks readers through the "where" and "how" of real-world Python programming with practical, actionable instruction. With a focus on real-world functionality, <i>Python Projects</i> details the ways that Python can be used to complete daily tasks and bring efficiency to businesses and individuals alike.<br /><br /><i>Python Projects</i> is written specifically for those who know the Python syntax and lay of the land, but may still be intimidated by larger, more complex projects. The book provides a walk-through of the basic set-up for an application and the building and packaging for a library, and explains in detail the functionalities related to the projects. Topics include:<br /><br />*How to maximize the power of the standard library modules<br />*Where to get third party libraries, and the best practices for utilization<br />*Creating, packaging, and reusing libraries within and across projects<br />*Building multi-layered functionality including networks, data, and user interfaces<br />*Setting up development environments and using virtualenv, pip, and more<br /><br />Written by veteran Python trainers, the book is structured for easy navigation and logical progression that makes it ideal for individual, classroom, or corporate training.<br /><br />For Python developers looking to apply their skills to real-world challenges, <i>Python Projects</i> is a goldmine of information and expert insight.<br />
<p>INTRODUCTION xxv</p> <p><b>CHAPTER 1: REVIEWING CORE PYTHON 1</b></p> <p>Exploring the Python Language and the Interpreter 2</p> <p>Reviewing the Python Data Types 3</p> <p>Numeric Types: Integer and Float 4</p> <p>The Boolean Type 5</p> <p>The None Type 6</p> <p>Collection Types 6</p> <p>Strings 7</p> <p>Bytes and ByteArrays 8</p> <p>Tuples 10</p> <p>Lists 10</p> <p>Dictionaries 12</p> <p>Sets 13</p> <p>Using Python Control Structures 15</p> <p>Structuring Your Program 15</p> <p>Using Sequences, Blocks and Comments 16</p> <p>Selecting an Execution Path 17</p> <p>Iteration 18</p> <p>Handling Exceptions 20</p> <p>Managing Context 21</p> <p>Getting Data In and Out of Python 21</p> <p>Interacting with Users 21</p> <p>Using Text Files 23</p> <p>Extending Python 24</p> <p>Defining and Using Functions 24</p> <p>Generator Functions 26</p> <p>Lambda Functions 27</p> <p>Defining and Using Classes and Objects 28</p> <p>Creating and Using Modules and Packages 33</p> <p>Using and Creating Modules 33</p> <p>Using and Creating Packages 34</p> <p>Creating an Example Package 36</p> <p>Using Third‐Party Packages 42</p> <p>Summary 43</p> <p><b>CHAPTER 2: SCRIPTING WITH PYTHON 47</b></p> <p>Accessing the Operating System 48</p> <p>Obtaining Information about Users and Their Computer 49</p> <p>Obtaining Information about the Current Process 53</p> <p>Managing Other Programs 55</p> <p>Managing Subprocesses More Effectively 58</p> <p>Obtaining Information about Files (and Devices) 60</p> <p>Navigating and Manipulating the File system 62</p> <p>Plumbing the Directory Tree Depths 69</p> <p>Working with Dates and Times 72</p> <p>Using the time Module 72</p> <p>Introducing the datetime Module 75</p> <p>Introducing the calendar Module 76</p> <p>Handling Common File Formats 76</p> <p>Using Comma‐Separated Values 76</p> <p>Working with Confi g Files 83</p> <p>Working with XML and HTML Files 86</p> <p>Parsing XML Files 86</p> <p>Parsing HTML Files 89</p> <p>Accessing Native APIs with ctypes and pywin32 93</p> <p>Accessing the Operating System Libraries 94</p> <p>Using ctypes with Windows 95</p> <p>Using ctypes on Linux 96</p> <p>Accessing a Windows Application Using COM 96</p> <p>Automating Tasks Involving Multiple Applications 98</p> <p>Using Python First 98</p> <p>Using Operating System Utilities 98</p> <p>Using Data Files 98</p> <p>Using a Third‐Party Module 99</p> <p>Interacting with Subprocesses via a CLI 99</p> <p>Using Web Services for Server‐Based Applications 99</p> <p>Using a Native Code API 100</p> <p>Using GUI Robotics 100</p> <p>Summary 100</p> <p><b>CHAPTER 3: MANAGING DATA 103</b></p> <p>Storing Data Using Python 104</p> <p>Using DBM as a Persistent Dictionary 104</p> <p>Using Pickle to Store and Retrieve Objects 109</p> <p>Accessing Objects with shelve 111</p> <p>Analyzing Data with Python 116</p> <p>Analyzing Data Using Built‐In Features of Python 116</p> <p>Analyzing Data with ittertools 119</p> <p>Utility Functions 119</p> <p>Data Processing Functions 121</p> <p>Taming the Vagaries of groupby() 122</p> <p>Using itertools to Analyze LendyDB Data 124</p> <p>Managing Data Using SQL 125</p> <p>Relational Database Concepts 126</p> <p>Structured Query Language 127</p> <p>Creating Tables 128</p> <p>Inserting Data 129</p> <p>Reading Data 130</p> <p>Modifying Data 133</p> <p>Linking Data across Tables 134</p> <p>Digging Deeper into Data Constraints 134</p> <p>Revisiting SQLite Field Types 135</p> <p>Modeling Relationships with Constraints 136</p> <p>Many‐to‐Many Relationships 140</p> <p>Migrating LendyDB to an SQL Database 143</p> <p>Accessing SQL from Python 143</p> <p>Using SQL Connections 143</p> <p>Using a Cursor 143</p> <p>Creating the LendyDB SQL Database 145</p> <p>Inserting Test Data 146</p> <p>Creating a LendyDB API 148</p> <p>Exploring Other Data Management Options 154</p> <p>Client‐Server Databases 154</p> <p>NoSQL 155</p> <p>The Cloud 155</p> <p>Data Analysis with RPy 156</p> <p>Summary 157</p> <p><b>CHAPTER 4: BUILDING DESKTOP APPLICATIONS 161</b></p> <p>Structuring Applications 162</p> <p>Building Command-Line Interfaces 164</p> <p>Building the Data Layer 164</p> <p>Building the Core Logic Layer 165</p> <p>Building the User Interface 169</p> <p>Using the cmd Module to Build a Command-Line Interface 173</p> <p>Reading Command-Line Arguments 175</p> <p>Jazzing Up the Command-Line Interface with Some Dialogs 177</p> <p>Programming GUIs with Tkinter 181</p> <p>Introducing Key GUI Principles 181</p> <p>Event‐Based Programming 181</p> <p>GUI Terminology 182</p> <p>The Containment Tree 183</p> <p>Building a Simple GUI 184</p> <p>Building a Tic‐Tac‐Toe GUI 186</p> <p>Sketching a UI Design 186</p> <p>Building Menus 187</p> <p>Building a Tic‐Tac‐Toe Board 188</p> <p>Connecting the GUI to the Game 190</p> <p>Extending Tkinter 194</p> <p>Using Tix 194</p> <p>Using ttk 198</p> <p>Revisiting the Lending Library 199</p> <p>Exploring Other GUI Toolkits for Python 206</p> <p>wxPython 207</p> <p>PyQt 207</p> <p>PyGTK 208</p> <p>Native GUIs: Cocoa and PyWin32 209</p> <p>Dabo 209</p> <p>Storing Local Data 210</p> <p>Storing Application‐Specific Data 210</p> <p>Storing User‐Selected Preferences 211</p> <p>Storing Application State 212</p> <p>Logging Error information 212</p> <p>Understanding Localization 214</p> <p>Using Locales 214</p> <p>Using Unicode in Python 216</p> <p>Using gettext 218</p> <p>Summary 220</p> <p><b>CHAPTER 5: PYTHON ON THE WEB 223</b></p> <p>Python on the Web 224</p> <p>Parts of a Web Application 225</p> <p>The Client‐Server Relationship 226</p> <p>Middleware and MVC 226</p> <p>HTTP Methods and Headers 227</p> <p>What Is an API? 230</p> <p>Web Programming with Python 235</p> <p>Using the Python HTTP Modules 235</p> <p>Creating an HTTP Server 235</p> <p>Exploring the Flask Framework 237</p> <p>Creating Data Models in Flask 238</p> <p>Creating Core Flask Files 239</p> <p>More on Python and the Web 247</p> <p>Static Site Generators 248</p> <p>Web Frameworks 248</p> <p>Using Python across the Wire 248</p> <p>XML‐RPC 249</p> <p>Socket Servers 250</p> <p>More Networking Fun in Python 253</p> <p>Summary 254</p> <p><b>CHAPTER 6: PYTHON IN BIGGER PROJECTS 257</b></p> <p>Testing with the Doctest Module 258</p> <p>Testing with the Unittest Module 262</p> <p>Test‐Driven Development in Python 267</p> <p>Debugging Your Python Code 267</p> <p>Handling Exceptions in Python 272</p> <p>Working on Larger Python Projects 276</p> <p>Releasing Python Packages 280</p> <p>Summary 282</p> <p><b>CHAPTER 7: EXPLORING PYTHON’S FRONTIERS 285</b></p> <p>Drawing Pictures with Python 286</p> <p>Using Turtle Graphics 286</p> <p>Using GUI Canvas Objects 286</p> <p>Plotting Data 287</p> <p>Using imghdr 287</p> <p>Introducing Pillow 287</p> <p>Trying Out ImageMagick 287</p> <p>Doing Science with Python 288</p> <p>Introducing SciPy 288</p> <p>Doing Bioscience with Python 290</p> <p>Using GIS 290</p> <p>Watching Your Language 290</p> <p>Getting It All 290</p> <p>Playing Games with Python 291</p> <p>Enriching the Experience with PyGame 291</p> <p>Exploring Other Options 291</p> <p>Going to the Movies 292</p> <p>The Computer Graphics Kit 292</p> <p>Modeling and Animation 292</p> <p>Photo Processing 292</p> <p>Working with Audio 293</p> <p>Integrating with Other Languages 293</p> <p>Jython 293</p> <p>IronPython 294</p> <p>Cython 294</p> <p>Tcl/Tk 295</p> <p>Getting Physical 296</p> <p>Introducing Serial Options 296</p> <p>Programming the RaspberryPi 296</p> <p>Talking to the Arduino 297</p> <p>Exploring Other Options 297</p> <p>Building Python 298</p> <p>Fixing Bugs 298</p> <p>Documenting 298</p> <p>Testing 299</p> <p>Adding Features 299</p> <p>Attending Conferences 299</p> <p>Summary 299</p> <p><b>APPENDIX A: ANSWERS TO EXERCISES 303</b></p> <p>Chapter 1 Solutions 303</p> <p>Chapter 2 Solutions 305</p> <p>Chapter 3 Solutions 306</p> <p>Chapter 4 Solutions 311</p> <p>Chapter 5 Solutions 315</p> <p>Chapter 6 Solutions 316</p> <p>Chapter 7 Solutions 317</p> <p><b>APPENDIX B: PYTHON STANDARD MODULES 319</b></p> <p><b>APPENDIX C: USEFUL PYTHON RESOURCES 327</b></p> <p>Asking Questions: Mailing Lists and More 327</p> <p>Reading Blogs 328</p> <p>Studying Tutorials and References 328</p> <p>Watching Videos 329</p> <p>And Now for Something Completely Different… 329</p> <p>REFERENCES 331</p> <p>INDEX 333</p>
<p><b>Laura Cassell</b> is the founder of PyLadies Atlanta. She taught Python and JavaScript for Big Nerd Ranch, and is now an engineering manager for the Python team at New Relic.</p> <p><b>Alan Gauld</b> is an enterprise architect working in the telecommunications and customer service industries. He has used Python since 1998, and is a moderator and active participant in the python-tutor mailing list.</p> <p><b>Wrox guides</b> are crafted to make learning programming languages and technologies easier than you think. Written by programmers for programmers, they provide a structured, tutorial format that will guide you through all the techniques involved.</p>
<p><b>Boost your Python skills with practical real-world projects</b></p> <p>Bridging the gap between learning and doing, this book walks you through the “where” and “how” of real-world Python programming with practical, actionable guidance. Focused on functionality, the hands-on instruction covers the basic application set-up and library construction and packaging to help you move beyond tutorials and start building projects, with the help of veteran Python trainers who provide valuable insight along the way. You should be familiar with the basic syntax of the core Python language, and ready to develop your skills to become proficient in the practical application of this top programming language.</p> <p><i>Python Projects:</i></p> <ul> <li>Learn how Python works in the real world to complete daily tasks and bring efficiency to business</li> <li>Discover how libraries work, where to use them, and the best places to get them</li> <li>Set up development environments using Virtualenv, Pip, and more</li> <li>Create, package, and share libraries with other users in the Python community</li> <li>Build projects with a layered approach, using libraries to add function at each iteration</li> <li>Apply Python to real-world intermediate-level projects to gain confidence for larger open-source projects</li> </ul> <p><b>Programmer Forums</b></p> <p>Join our Programmer to Programmer forums to ask and answer programming questions about this book, join discussions on the hottest topics in the industry, and connect with fellow programmers from around the world.</p> <p><b>Code Downloads</b></p> <p>Take advantage of free code samples from this book, as well as code samples from hundreds of other books, all ready to use.</p> <p><b>Read More</b></p> <p>Find articles, e-books, sample chapters and tables of contents for hundreds of books, and more reference resources on programming topics that matter to you.</p>

Diese Produkte könnten Sie auch interessieren:

Domain Architectures
Domain Architectures
von: Daniel J. Duffy
PDF ebook
31,99 €