Python 3 for Absolute Beginners.pdf.pdf

所需积分/C币:10 2019-09-15 23:19:37 1.67MB PDF
收藏 收藏

Python 3 for Absolute Beginners.pdf
Contents at a Glance Contents ■■■■■ About the Author mm Xi About the Technical reviewer oducing Python,,,…,,…,,,…,…,…,,…,,…,…, Chapter 2: Designing Software ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■■■口 9 Chapter 3: Variables and Data Types.aan ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 27 Chapter 4: Making Choices. ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 49 Chapter 5: Using Lists. ■■■■■■■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■ 75 Chapter 6: Functions ammmammmammmmmmmamammmmmmammman 101 Chapter 7: Working with Text 125 Chapter 8: Executable Files, Organization, and Python on the Web mm 161 Chapter 9: classes mB BRBBRRRIaE n181 Chapter 10: Exceptions ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 221 Chapter 11: Reusing Code with Modules and Packages ■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■■■ 241 Chapter 12: Simple Windowed Applications mma m aaAa 261 Index ua283 Contents About the author ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ About the technical reviewer ■■■■■■■■■■■ Chapter 1: Introducing Python maar ■■■■■■■■■■■■■■■ Running Python on Various Systems earning While Having Fun Introducing the Interactive shell Choosing to Code with a Text Editor 445 Choosing to Code with an Integrated Development Environment 5 Getting Started with Programming. 5 Creating Your Own Help Files Jargon Busting 6 Summary…..............7 Chapter 2: Designing Software mBBBIBRRRBBRBE REIRMIIIRIIIIII 9 Designing Your Own Software Why Bother?) 9 Identifying the Problem…… 10 Creating Your Wish List 12 Devising a Solution mm.mmnmnmmnnmnnnnn 13 Breaking Down the Solution into Steps 15 Jargon Busting 24 Summary….,,,,,…………25 Chapter 3: Variables and Data Types. 27 Choosing good identifiers. Creating Variables and Assigning values. Recognizing Different Types of variables 29 Jargon Busting… ■■■■■ ■■■ 5 CONTENTS Summary 247 Chapter 4: Making Choices. ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 9 Comparing Things. Taking control of the Process 55 Dealing with logical Errors 57 Using Conditional Code in the application 61 Now Repeat That 165 Jargon Busting 73 Summary 74 Chapter 5: Using Lists. ■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■■■ 75 Working with Python Data Structures 75 Tuples 79 Lists ….80 Sets 85 Dictionaries 86 A Simple Role-Playing Combat Game Jargon Busting 99 Summary…..,,………100 Chapter6: Functions,,,,,,,,,,,,,,,,:,:101 Accessing Privileged Information n101 Working with Variable Scope 105 Refactoring rpcombat py to Reduce Repetition 108 Jargon Busting .mmm........ n, 123 Summary 124 Chapter 7: Working with Text aar uu125 Strings and Things…… 125 Matching Patterns Using Regular Expressions 135 Using Files ......................................................................141 Applications 145 Jargon Busting.……………159 Summary 160 CONTENTS Chapter 8: Executable Files, Organization, and Python on the Webmmmmm 161 Making Programs Executable as Stand- Alone Applications….,.,…,…161 Organizing your project 164 Writing Stylish Code…… 165 porting Modules...,.,..,.,.,,,,,,,,,,,170 Using execo and eval 172 Putting Python on the Web 173 Jargon Busting…… 179 Summary 179 Chapter 9: classes ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■ 181 Empowering objects 182 When should classes be used? 185 Customizing 191 Application 200 Jargon Busting 219 Summary 220 Chapter 10: Exceptions.mmmamam 221 When Something Goes Wrong 221 Classes of exceptions . A Final Note on Pythonic Exception Handling 238 Jargon Busting 239 Summary 240 Chapter 11: Reusing Code with Modules and Packages mm tIanmiN 241 Understanding Python Modules 241 Everyday Module Usagemmmm Advanced module behavior 249 Combining modules into Packages 252 The Universe of Python packages Jargon Busting 259 Summary nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnDnnDnnD 260 CONTENTS Chapter 12: Simple Windowed mmanaaIaEaa. 261 Using Tkinter 261 Saying“Helo” with PyGTK…...........……265 Using Glade and tepache to Build Interfaces 279 Jargon busting . Summary 292 Index 283 About the author Tim Hall currently provides front-line support for 64 Studio. He has also written newbie tutorials for Linux User and Developer magazine in between more mundane system admin and web authoring jobs Tim has released albums and performed as a musician and songwriter, both solo and in collaboration with other artists he has been further honored as the holder of the bardic chair of glastonbury between 2005 and 2007. Tim uses Python as his main programming language, primarily as a means for creative ends, because it is easy to read and fun to learn J-P Stacey has been a senior developer at Torchbox Ltd since 2005, building and maintaining (among other things)Python, Django, and Drupal applications He organizes the oxford Geek Nights and gets involved in tuition and seminars at Torchbox In his spare time he reads and writes fiction and blogs, buys too much music, and tries not to startle Cotswold lions on his bicycle About the technical reviewer Duncan Parkes has been coding in Python, both for work and for fun, for roughly a decade. He drifted into programming largely by accident after initially taking a doctorate in Combinatorial Group Theory, a branch of Pure Mathematics. As an ex-mathematician, he loves the clarity and simplicity of Python and needs a bit of persuading to code in anything else. After completing a technical review of this book, he joined Apress as an editor in the Open Source group He currently splits his time between editing books and coding g for mySociety, a charitable e organization that runs most of the UK's best-known democracy web sites Duncan lives in Oxford, England, with his wife, Ruth. When away from his computer, Duncan enjoys playing the guitar very badly, cycling long distances on a Brompton folding bicycle, and fiddling with old cars His friends and colleagues have been known to run sweepstakes on how far these vehicles can get without the assistance of a breakdown service CHAPTER 1 Introducing Python So, you want to learn programming. Welcome to one of the great adventures of the twenty-first century. Programming requires little in the way of specialized equipment; the software tools can all be downloaded for free off the Internet, and it can be practiced in the safety and comfort of your own home without having to ask anyone's permission. This chapter will ease you in gently by introducing you to the software you will need to create your programs: a command-line interface, which allows you to use Python in interactive mode, and a text editor for writing scripts--nothing more complicated than that. I will also show you where to go to find help and documentation, so you can decode the sometimes impenetrable jargon that seems to surround this, the geekiest of all technical disciplines. To begin with, you will need to make sure that you have a decently recent version of Python installed on your machine or follow the steps later in this chapter to install it(see"Choosing the Right Python Version"for a definition of decently recent). This chapter explains how to make sure that you have everything set up correctly and that you have suitable references at hand before you start your journey Python is an excellent language with which to learn programming. There are many reasons for this but the simple explanation is that it's easy to read and fast to write; it doesn 't take long to come up with working code that does something meaningful. Python has a very human-friendly syntax, which makes writing elegant code easy. The basic language is fairly simple and therefore easy to remember, and then it has an extensive library of predefined functions that you can use to facilitate most common computer tasks. Writing effective applications in Python can be as simple as playing with conceptual building blocks. It works really well for writing a little two-line application to perform some routine system administration task or to provide interactive functions on a web page, but it has enough power and flexibility to comfortably create much larger and more complex applications with graphic interfaces indistinguishable from the programs you are used to running from your computer's main menu. If you follow the suggestions laid out in this book about writing self-explanatory code, in several months, even years, you will be able to come back to your programs and see immediately what they were supposed to do and what your original intentions were; this makes maintaining programs much simpler too OK, let's make sure your system is ready for you to start running Python programs Running Python on Various Systems Python can be installed and run on most operating systems including Windows, Mac OS X, or OS/2 Linux, and Unix. If you are running Mac OS Xor a GNU/Linux system, you will probably have it installed by default. I would recommend using a system of this kind, which already has Python set up as an integral part. The book was written using a Debian GNU/Linux system, and therefore, the examples will

试读 300P Python 3 for Absolute Beginners.pdf.pdf
立即下载 低至0.43元/次 身份认证VIP会员低至7折
    • 至尊王者


    关注 私信 TA的资源

    Python 3 for Absolute Beginners.pdf.pdf 10积分/C币 立即下载
    Python 3 for Absolute Beginners.pdf.pdf第1页
    Python 3 for Absolute Beginners.pdf.pdf第2页
    Python 3 for Absolute Beginners.pdf.pdf第3页
    Python 3 for Absolute Beginners.pdf.pdf第4页
    Python 3 for Absolute Beginners.pdf.pdf第5页
    Python 3 for Absolute Beginners.pdf.pdf第6页
    Python 3 for Absolute Beginners.pdf.pdf第7页
    Python 3 for Absolute Beginners.pdf.pdf第8页
    Python 3 for Absolute Beginners.pdf.pdf第9页
    Python 3 for Absolute Beginners.pdf.pdf第10页
    Python 3 for Absolute Beginners.pdf.pdf第11页
    Python 3 for Absolute Beginners.pdf.pdf第12页
    Python 3 for Absolute Beginners.pdf.pdf第13页
    Python 3 for Absolute Beginners.pdf.pdf第14页
    Python 3 for Absolute Beginners.pdf.pdf第15页
    Python 3 for Absolute Beginners.pdf.pdf第16页
    Python 3 for Absolute Beginners.pdf.pdf第17页
    Python 3 for Absolute Beginners.pdf.pdf第18页
    Python 3 for Absolute Beginners.pdf.pdf第19页
    Python 3 for Absolute Beginners.pdf.pdf第20页


    10积分/C币 立即下载 >