Download Python Descriptors by Jacob Zimmerman PDF

By Jacob Zimmerman

ISBN-10: 148422504X

ISBN-13: 9781484225042

ISBN-10: 1484225058

ISBN-13: 9781484225059

This brief booklet on Python descriptors is a set of data and concepts from many assets on facing and developing descriptors. And, after dealing with the issues all descriptors have in universal, the writer explores rules that experience a number of methods of being carried out in addition to thoroughly new rules by no means obvious in different places before.

This really is a accomplished advisor to making Python descriptors. As an advantage: A pip install-able library, descriptor_tools, used to be written along this e-book and is an open resource library on GitHub.

There are not many stable assets available in the market for writing Python descriptors, and intensely few books. it is a unhappy scenario, because it makes it tough for Python builders to get a truly reliable figuring out of the way descriptors paintings and the strategies to prevent the massive gotchas linked to operating with them.
What you'll Learn

  • Discover descriptor protocols
  • Master characteristic entry and the way it applies to descriptors
  • Make descriptors and observe why you should
  • Store attributes
  • Create read-only descriptors and _delete()
  • Explore the descriptor classes
  • Apply the opposite makes use of of descriptors and more

Who This publication Is For
Experienced Python coders, programmers and developers.

Show description

Read or Download Python Descriptors PDF

Similar python books

Learning Python: Powerful Object-Oriented Programming (4th Edition)

Google and YouTube use Python simply because it's hugely adaptable, effortless to take care of, and enables swift improvement. so that you can write top of the range, effective code that's simply built-in with different languages and instruments, this hands-on booklet may also help you be efficient with Python fast -- no matter if you're new to programming or simply new to Python.

Real Python: An Introduction to Python Through Practical Examples

An booklet to educate programming via hands-on, attention-grabbing examples which are important and fun!

Python is a brilliant programming language. It's unfastened, robust, more uncomplicated to learn than such a lot languages, and has extensions to be had to do nearly something you may think automatically.

But how do you certainly use it? There are lots of assets in the market for studying Python, yet none of them are very functional or fascinating - as a substitute, they pass over every one thought one after the other, by no means tying something jointly, yet spending lots of time misplaced in technical language, discussing the twenty alternative ways to complete each one uncomplicated activity. ..

I are looking to write an book that at last supplies a concise advent to every thing you could really are looking to do with Python.

We'll begin with a short yet thorough evaluate of all of the fundamentals, so that you don't even want any past adventure with programming. however the majority of the booklet might be spent increase instance code to resolve attention-grabbing real-world problems.

Python is astounding for automating repetitive initiatives that would in a different way take you hours - for example, fast accumulating information from the internet, or renaming hundreds and hundreds of documents. the various subject matters that I'm making plans to cover:

Collecting facts from webpages (web scraping)
Interacting with PDF records - examining information, growing PDFs, enhancing pages, including passwords. ..
Interacting with Excel documents (less performance in OS X)
Calling different outdoor courses from inside of Python
Files - read/write/modify, unzip, rename, stream, etc.
Basic online game development
Interacting with SQL databases (internal and ODBC connections)
GUI (Graphical person Interface) layout - growing uncomplicated point-and-click courses that any one can use
Any different themes that you just, my backers, are so much in!
Update: by way of well known call for, I'll be including internet program development

All comparable path fabrics downloadable at: http://www. psychotix. com/share/Real_Python. zip

Python Algorithms: Mastering Basic Algorithms in the Python Language

Python Algorithms explains the Python method of set of rules research and layout.

Written through Magnus Lie Hetland, writer of starting Python, this booklet is sharply inquisitive about classical algorithms, however it additionally provides a great knowing of primary algorithmic problem-solving strategies.

The e-book offers with the most very important and difficult components of programming and desktop technological know-how, yet in a hugely pedagogic and readable manner.

The e-book covers either algorithmic concept and programming perform, demonstrating how thought is mirrored in genuine Python programs.

Well-known algorithms and information buildings which are equipped into the Python language are defined, and the consumer is proven tips to enforce and review others himself.

Testing Python: Applying Unit Testing, TDD, BDD and Acceptance Testing

Primary checking out methodologies utilized to the preferred Python language

Testing Python; making use of Unit checking out, TDD, BDD and recognition trying out is the main finished publication to be had on trying out for one of many best software program programming languages on the planet. Python is a average selection for brand spanking new and skilled builders, and this hands-on source is a far wanted advisor to enterprise-level trying out improvement methodologies. The ebook will express you why Unit trying out and TDD can result in cleanser, extra versatile programs.

Unit checking out and Test-Driven improvement (TDD) are more and more must-have talents for software program builders, it doesn't matter what language they paintings in. In company settings, it's serious for builders to make sure they consistently have operating code, and that's what makes checking out methodologies so appealing. This publication will train you the main established trying out suggestions and should introduce to you to nonetheless others, protecting functionality checking out, non-stop checking out, and more.

Learn Unit trying out and TDD—important improvement methodologies that lie on the middle of Agile development
Enhance your skill to paintings with Python to strengthen robust, versatile functions with fresh code
Draw at the services of writer David Sale, a number one united kingdom developer and tech commentator
Get prior to the gang via studying the underappreciated global of Python testing
Knowledge of software program checking out in Python may perhaps set you except Python builders utilizing superseded methodologies. Python is a normal healthy for TDD and trying out Python is a must-read textual content for a person who desires to increase services in Python programming.

Additional resources for Python Descriptors

Sample text

There needs to be some sort of back door. Three different techniques will be discussed: set-once, secret-set, and forced-set. Set-Once Descriptors A set-once descriptor is the most restrictive of the three read-only properties in that it most strongly restricts the number of assignments to once per instance under it. Set-once descriptors work simply by checking whether a value is already set and acting accordingly. If it's already assigned, it raises an exception; if it's not, then it sets it. For example, this is what the basic __set__() method would look like if the descriptor was using on-descriptor storage in the instance attribute, storage.

While this is a good idea regardless, it’s worth mentioning that it may fail in some cases. If you want to make a descriptor safe with __slots__ while still defaulting to using __dict__, you may want to create some sort of alternative that uses on-descriptor storage when a boolean flag is set on creation. There are plenty of ways to implement that, whether using a factory that chooses a different descriptor if the flag is set or the class within has alternate paths based on the flag value. Another, simpler alternative is to document the name that the descriptor stores its values under so that users of the 33 Chapter 7 ■ Storing the Attributes descriptor who want to use __slots__ can prepare a slot for it.

Summary We’ve seen that __delete__() is a pretty simple method to implement, but deciding whether to actually implement it or not can be a difficult decision. In the end, though, it will be used so little that implementing it can probably be put off until it's needed. The default behavior of raising an exception due to lack of implementation should get you by until then. © Jacob Zimmerman 2016 J. 1007/978-1-4842-2505-9_9 47 CHAPTER 10 Descriptors are Classes Too It’s time for some more advanced stuff with descriptors.

Download PDF sample

Rated 4.24 of 5 – based on 27 votes