39%
Professional Python

Professional Python

4.5       |  2 Reviews 
5
4
3
2
1

Out of Stock


Premium quality
Premium quality
Bookswagon upholds the quality by delivering untarnished books. Quality, services and satisfaction are everything for us!
Easy Return
Easy return
Not satisfied with this product! Keep it in original condition and packaging to avail easy return policy.
Certified product
Certified product
First impression is the last impression! Address the book’s certification page, ISBN, publisher’s name, copyright page and print quality.
Secure Checkout
Secure checkout
Security at its finest! Login, browse, purchase and pay, every step is safe and secured.
Money back guarantee
Money-back guarantee:
It’s all about customers! For any kind of bad experience with the product, get your actual amount back after returning the product.
On time delivery
On-time delivery
At your doorstep on time! Get this book delivered without any delay.
Notify me when this book is in stock
Add to Wishlist

About the Book

Master the secret tools every Python programmer needs to know Professional Python goes beyond the basics to teach beginner- and intermediate-level Python programmers the little-known tools and constructs that build concise, maintainable code. Design better architecture and write easy-to-understand code using highly adoptable techniques that result in more robust and efficient applications. Coverage includes Decorators, Context Managers, Magic Methods, Class Factories, Metaclasses, Regular Expressions, and more, including advanced methods for unit testing using asyncio and CLI tools. Each topic includes an explanation of the concept and a discussion on applications, followed by hands-on tutorials based on real-world scenarios. The "Python 3 first" approach covers multiple current versions, while ensuring long-term relevance. Python offers many tools and techniques for writing better code, but often confusing documentation leaves many programmers in the dark about how to use them. This book shines a light on these incredibly useful methods, giving you clear guidance toward building stronger applications. Learn advanced Python functions, classes, and libraries Utilize better development and testing tools Understand the "what," "when," "why," and "how" More than just theory or a recipe-style walk-through, this guide helps you learn — and understand — these little-known tools and techniques. You'll streamline your workflow while improving the quality of your output, producing more robust applications with cleaner code and stronger architecture. If you're ready to take your Python skills to the next level, Professional Python is the invaluable guide that will get you there.

Table of Contents:
Introduction xxv Part I: Functions Chapter 1: Decorators 3 Understanding Decorators 3 Decorator Syntax 4 Order of Decorator Application 5 Where Decorators Are Used 6 Why You Should Write Decorators 6 When You Should Write Decorators 7 Additional Functionality 7 Data Sanitization or Addition 7 Function Registration 7 Writing Decorators 7 An Initial Example: A Function Registry 7 Execution-Time Wrapping Code 9 A Simple Type Check 9 Preserving the help 10 User Verification 11 Output Formatting 12 Logging 14 Variable Arguments 15 Decorator Arguments 16 How Does This Work? 17 The Call Signature Matters 18 Decorating Classes 20 Type Switching 22 A Pitfall 24 Summary 25 Chapter 2: Context Managers 27 What Is a Context Manager? 27 Context Manager Syntax 28 The with Statement 28 The enter and exit Methods 28 Exception Handling 29 When You Should Write Context Managers 30 Resource Cleanliness 30 Avoiding Repetition 31 Propagating Exceptions 31 Suppressing Exceptions 32 A Simpler Syntax 37 Summary 38 Chapter 3: Generators 41 Understanding What a Generator Is 41 Understanding Generator Syntax 41 The next Function 43 The StopIteration Exception 45 Python 2 46 Python 3 47 Communication with Generators 47 Iterables Versus Iterators 49 Generators in the Standard Library 50 range 50 dict.items and Family 50 zip 51 map 51 File Objects 52 When to Write Generators 53 Accessing Data in Pieces 53 Computing Data in Pieces 54 Sequences Can Be Infinite 54 When Are Generators Singletons? 54 Generators within Generators 55 Summary 56 Part II: Classes Chapter 4: Magic Methods 59 Magic Method Syntax 59 Available Methods 60 Creation and Destruction 61 __init__ 61 __new__ 62 __del__ 62 Type Conversion 63 __str__, __unicode__, and __bytes__ 63 __bool__ 64 __int__, __fl oat__, and __complex__ 65 Comparisons 65 Binary Equality 65 Relative Comparisons 67 Operator Overloading 68 Overloading Common Methods 71 Collections 75 Other Magic Methods 77 Summary 77 Chapter 5: Metaclasses 79 Classes and Objects 79 Using type Directly 80 Creating a Class 81 Creating a Subclass 81 The type Chain 82 The Role of type 82 Writing Metaclasses 83 The new Method 83 new Versus init 83 A Trivial Metaclass 84 Metaclass Inheritance 84 Using Metaclasses 87 Python 3 87 Python 2 88 What About Code That Might Run on Either Version? 88 When Is Cross-Compatibility Important? 89 When to Use Metaclasses 89 Declarative Class Declaration 89 An Existing Example 89 How This Works 90 Why This Is a Good Use for Metaclasses 91 Class Verification 91 Non-Inheriting Attributes 93 The Question of Explicit Opt-In 94 Meta-Coding 95 Summary 97 Chapter 6: Class Factories 99 A Review of type 99 Understanding a Class Factory Function 100 Determining When You Should Write Class Factories 102 Runtime Attributes 102 Understanding Why You Should Do This 103 Attribute Dictionaries 104 Fleshing Out the Credential Class 104 The Form Example 105 Dodging Class Attribute Consistency 106 Class Attributes Versus Instance Attributes 107 The Class Method Limitation 108 Tying This in with Class Factories 109 Answering the Singleton Question 109 Summary 111 Chapter 7: Abstract Base Classes 113 Using Abstract Base Classes 113 Declaring a Virtual Subclass 115 Why Declare Virtual Subclasses? 115 Using register as a Decorator 117 __subclasshook__ 117 Declaring a Protocol 119 Other Existing Approaches 119 Using NotImplementedError 120 Using Metaclasses 120 The Value of Abstract Base Classes 122 Abstract Properties 124 Abstract Class or Static Methods 125 Built-in Abstract Base Classes 126 Single-Method ABCs 126 Alternative-Collection ABCs 127 Using Built-In Abstract Base Classes 128 Additional ABCs 128 Summary 128 Part III: Data Chapter 8: Strings And Unicode 131 Text String Versus Byte String 131 String Data in Python 132 Python 3 Strings 132 Python 2 Strings 134 six 136 Strings with Non-ASCII Characters 136 Observing the Difference 136 Unicode Is a Superset of ASCII 137 Other Encodings 137 Encodings Are Not Cross-Compatible 138 Reading Files 139 Python 3 139 Specifying Encoding 139 Reading Bytes 140 Python 2 140 Reading Other Sources 141 Specifying Python File Encodings 141 Strict Codecs 143 Suppressing Errors 143 Registering Error Handlers 144 Summary 145 Chapter 9: Regular Expressions 147 Why Use Regular Expressions? 147 Regular Expressions in Python 148 Raw Strings 148 Match Objects 149 Finding More Than One Match 149 Basic Regular Expressions 150 Character Classes 150 Ranges 151 Negation 151 Shortcuts 152 Beginning and End of String 153 Any Character 154 Optional Characters 154 Repetition 155 Repetition Ranges 155 Open-Ended Ranges 156 Shorthand 156 Grouping 157 The Zero Group 159 Named Groups 159 Referencing Existing Groups 160 Lookahead 161 Flags 163 Case Insensitivity 163 ASCII and Unicode 163 Dot Matching Newline 163 Multiline Mode 164 Verbose Mode 164 Debug Mode 164 Using Multiple Flags 165 Inline Flags 165 Substitution 165 Compiled Regular Expressions 166 Summary 167 Part IV: Everything Else Chapter 10: Python 2 Versus Python 3 171 Cross-Compatibility Strategies 171 The __future__ Module 172 2to3 172 Writing Changes 173 Limitations 174 six 174 Changes in Python 3 175 Strings and Unicode 175 The print Function 176 Division 176 Absolute and Relative Imports 177 Removal of “Old-Style” Classes 178 Metaclass Syntax 179 six.with_metaclass 179 six.add_metaclass 180 Exception Syntax 180 Handling Exceptions 181 Exception Chaining 181 Dictionary Methods 182 Function Methods 183 Iterators 183 Standard Library Relocations 184 Merging “Fast” Modules 184 io 184 pickle 184 The URL Modules 185 Renames 185 Other Package Reorganizations 185 Version Detection 186 Summary 186 Chapter 11: Unit Testing 187 The Testing Continuum 187 The Copied Ecosystem 188 The Isolated Environment 188 Advantages and Disadvantages 189 Speed 189 Interactivity 189 Testing Code 190 Code Layout 190 Testing the Function 191 The assert Statement 192 Unit Testing Frameworks 192 Running Unit Tests 193 Failures 193 Errors 194 Skipped Tests 195 Loading Tests 196 Mocking 197 Mocking a Function Call 197 Asserting Mocked Calls 199 Inspecting Mocks 201 Call Count and Status 201 Multiple Calls 202 Inspecting Calls 203 Other Testing Tools 203 coverage 203 tox 204 Other Test Runners 205 Summary 205 Chapter 12: Cli Tools 207 optparse 207 A Simple Argument 207 name == ‘ main__’ 208 OptionParser 208 Options 209 Types of Options 209 Adding Options to OptionParser 209 Options with Values 210 Non-String Values 211 Specifying Option Values 212 Positional Arguments 214 Counters 214 List Values 215 Why Use optparse? 216 argparse 216 The Bare Bones 217 Arguments and Options 217 Option Flags 217 Alternate Prefixes 218 Options with Values 219 Positional Arguments 222 Reading Files 223 Why Use argparse? 224 Summary 224 Chapter 13: Asyncio 225 The Event Loop 225 A Simple Event Loop 226 Running the Loop 226 Registering Tasks and Running the Loop 227 Delaying Calls 227 Partials 228 Running the Loop until a Task Completes 228 Running a Background Loop 229 Coroutines 230 Nested Coroutines 231 Futures and Tasks 232 Futures 232 Tasks 232 Callbacks 234 No Guarantee of Success 235 Under the Hood 235 Callbacks with Arguments 235 Task Aggregation 236 Gathering Tasks 236 Waiting on Tasks 237 Timeouts 238 Waiting on Any Task 239 Waiting on an Exception 239 Queues 240 Maximum Size 242 Servers 242 Summary 244 Chapter 14: STYLE 245 Principles 245 Assume Your Code Will Require Maintenance 245 Be Consistent 246 Think About Ontology, Especially with Data 246 Do Not Repeat Yourself 246 Have Your Comments Explain the Story 247 Occam’s Razor 247 Standards 248 Trivial Rules 248 Documentation Strings 248 Blank Lines 249 Imports 249 Variables 250 Comments 250 Line Length 251 Summary 251 Index 253


Best Sellers


Product Details
  • ISBN-13: 9781119070856
  • Publisher: John Wiley & Sons Inc
  • Publisher Imprint: Wrox Press
  • Depth: 13
  • Height: 234 mm
  • No of Pages: 288
  • Series Title: English
  • Weight: 522 gr
  • ISBN-10: 1119070856
  • Publisher Date: 24 Nov 2015
  • Binding: Paperback
  • Edition: PAP/PSC
  • Language: English
  • Returnable: N
  • Spine Width: 15 mm
  • Width: 185 mm


Similar Products

How would you rate your experience shopping for books on Bookswagon?

Add Photo
Add Photo

Customer Reviews

4.5       |  2 Reviews 
out of (%) reviewers recommend this product
Top Reviews
Rating Snapshot
Select a row below to filter reviews.
5
4
3
2
1
Average Customer Ratings
4.5       |  2 Reviews 
00 of 0 Reviews
Sort by :
Active Filters

00 of 0 Reviews
SEARCH RESULTS
1–2 of 2 Reviews
    BoxerLover2 - 5 Days ago
    A Thrilling But Totally Believable Murder Mystery

    Read this in one evening. I had planned to do other things with my day, but it was impossible to put down. Every time I tried, I was drawn back to it in less than 5 minutes. I sobbed my eyes out the entire last 100 pages. Highly recommend!

    BoxerLover2 - 5 Days ago
    A Thrilling But Totally Believable Murder Mystery

    Read this in one evening. I had planned to do other things with my day, but it was impossible to put down. Every time I tried, I was drawn back to it in less than 5 minutes. I sobbed my eyes out the entire last 100 pages. Highly recommend!


Sample text
Photo of
    Media Viewer

    Sample text
    Reviews
    Reader Type:
    BoxerLover2
    00 of 0 review

    Your review was submitted!
    Professional Python
    John Wiley & Sons Inc -
    Professional Python
    Writing guidlines
    We want to publish your review, so please:
    • keep your review on the product. Review's that defame author's character will be rejected.
    • Keep your review focused on the product.
    • Avoid writing about customer service. contact us instead if you have issue requiring immediate attention.
    • Refrain from mentioning competitors or the specific price you paid for the product.
    • Do not include any personally identifiable information, such as full names.

    Professional Python

    Required fields are marked with *

    Review Title*
    Review
      Add Photo Add up to 6 photos
      Would you recommend this product to a friend?
      Tag this Book
      Read more
      Does your review contain spoilers?
      What type of reader best describes you?
      I agree to the terms & conditions
      You may receive emails regarding this submission. Any emails will include the ability to opt-out of future communications.

      CUSTOMER RATINGS AND REVIEWS AND QUESTIONS AND ANSWERS TERMS OF USE

      These Terms of Use govern your conduct associated with the Customer Ratings and Reviews and/or Questions and Answers service offered by Bookswagon (the "CRR Service").


      By submitting any content to Bookswagon, you guarantee that:
      • You are the sole author and owner of the intellectual property rights in the content;
      • All "moral rights" that you may have in such content have been voluntarily waived by you;
      • All content that you post is accurate;
      • You are at least 13 years old;
      • Use of the content you supply does not violate these Terms of Use and will not cause injury to any person or entity.
      You further agree that you may not submit any content:
      • That is known by you to be false, inaccurate or misleading;
      • That infringes any third party's copyright, patent, trademark, trade secret or other proprietary rights or rights of publicity or privacy;
      • That violates any law, statute, ordinance or regulation (including, but not limited to, those governing, consumer protection, unfair competition, anti-discrimination or false advertising);
      • That is, or may reasonably be considered to be, defamatory, libelous, hateful, racially or religiously biased or offensive, unlawfully threatening or unlawfully harassing to any individual, partnership or corporation;
      • For which you were compensated or granted any consideration by any unapproved third party;
      • That includes any information that references other websites, addresses, email addresses, contact information or phone numbers;
      • That contains any computer viruses, worms or other potentially damaging computer programs or files.
      You agree to indemnify and hold Bookswagon (and its officers, directors, agents, subsidiaries, joint ventures, employees and third-party service providers, including but not limited to Bazaarvoice, Inc.), harmless from all claims, demands, and damages (actual and consequential) of every kind and nature, known and unknown including reasonable attorneys' fees, arising out of a breach of your representations and warranties set forth above, or your violation of any law or the rights of a third party.


      For any content that you submit, you grant Bookswagon a perpetual, irrevocable, royalty-free, transferable right and license to use, copy, modify, delete in its entirety, adapt, publish, translate, create derivative works from and/or sell, transfer, and/or distribute such content and/or incorporate such content into any form, medium or technology throughout the world without compensation to you. Additionally,  Bookswagon may transfer or share any personal information that you submit with its third-party service providers, including but not limited to Bazaarvoice, Inc. in accordance with  Privacy Policy


      All content that you submit may be used at Bookswagon's sole discretion. Bookswagon reserves the right to change, condense, withhold publication, remove or delete any content on Bookswagon's website that Bookswagon deems, in its sole discretion, to violate the content guidelines or any other provision of these Terms of Use.  Bookswagon does not guarantee that you will have any recourse through Bookswagon to edit or delete any content you have submitted. Ratings and written comments are generally posted within two to four business days. However, Bookswagon reserves the right to remove or to refuse to post any submission to the extent authorized by law. You acknowledge that you, not Bookswagon, are responsible for the contents of your submission. None of the content that you submit shall be subject to any obligation of confidence on the part of Bookswagon, its agents, subsidiaries, affiliates, partners or third party service providers (including but not limited to Bazaarvoice, Inc.)and their respective directors, officers and employees.

      Accept

      New Arrivals


      Inspired by your browsing history


      Your review has been submitted!

      You've already reviewed this product!
      ASK VIDYA