Quotes About Python
This description requires elaboration when the value and the slice being assigned overlap: L[2:5]=L[3:6], for instance, works fine because the value to be inserted is fetched before the deletion happens on the left.
~ Unknown
BazillionQuotes.com
__next__ raises a built-in StopIteration exception at end-of-file
~ Unknown
BazillionQuotes.com
for calls iter, which calls __iter__
~ Unknown
BazillionQuotes.com
you can do everything in Python that you can in Perl, but
~ Unknown
BazillionQuotes.com
In fact, within Python, instance and class objects are mostly just dictionaries with links between them.
~ Unknown
BazillionQuotes.com
Although we could implement all class behavior as method functions, operator overloading lets objects be more tightly integrated with Python's object model.
~ Unknown
BazillionQuotes.com
Every time you use an expression of the form object.attr where object is an instance or class object, Python searches the namespace tree from bottom to top, beginning with object, looking for the first attr it can find.
~ Unknown
BazillionQuotes.com
Python "best practice" rule of thumb is to use docstrings for functional documentation (what your objects do) and hash-mark comments for more micro-level documentation (how arcane bits of code work).
~ Unknown
BazillionQuotes.com
Although it's possible to emulate true access controls in Python classes, this is rarely done in practice, even for large systems.
~ Unknown
BazillionQuotes.com
Technically, __str__ is preferred by print and str, and __repr__ is used as a fallback for these roles and in all other contexts.
~ Unknown
BazillionQuotes.com
In Python, practicality often beats aesthetics.
~ Unknown
BazillionQuotes.com
Because shelves are Python objects containing Python objects, we can process them with normal Python syntax and development modes. Here, the interactive prompt effectively becomes a database client:
~ Unknown
BazillionQuotes.com
Of course, as I've pointed out numerous times in this book, type checking is usually the wrong thing to do in Python programs (we code to object interfaces, not object types), and the more general isinstance built-in is more likely what you'll want to use in the rare cases where instance class types must be queried.
~ Unknown
BazillionQuotes.com
This search order is called the new-style MRO for "method resolution order" (and often just MRO for short when used in contrast with the DFLR order). Despite the name, this is used for all attributes in Python, not just methods.
~ Unknown
BazillionQuotes.com
Notice that compilation happens when a file is being imported. Because of this, you will not usually see a .pyc byte code file for the top-level file of your program, unless it is also imported elsewhere — only imported files leave behind .pyc files on your machine.
~ Unknown
BazillionQuotes.com
A better and less commonly used solution would be to use two underscores at the front of the method name only: __gatherAttrs for us. Python automatically expands such names to include the enclosing class's name, which makes them truly unique when looked up by the inheritance search. This is a feature usually called pseudoprivate class attributes, which we'll expand on in Chapter 31 and deploy in an expanded version of this class there.
~ Unknown
BazillionQuotes.com
Python has a host of tools that most would consider functional in nature, which we enumerated in the preceding chapter — closures, generators, lambdas, comprehensions, maps, decorators, function objects, and more.
~ Unknown
BazillionQuotes.com
Interestingly, the iteration protocol is even more pervasive in Python today than the examples so far have demonstrated — essentially everything in Python's built-in toolset that scans an object from left to right is defined to use the iteration protocol on the subject object.
~ Unknown
BazillionQuotes.com
In Chapter 32, we'll also meet Python static methods (akin to those in C++), which are just self-less functions that usually process class attributes.
~ Unknown
BazillionQuotes.com
PYTHONPATH and .pth files offer more permanent ways to modify the path — the first per user, and the second per installation.
~ Unknown
BazillionQuotes.com
composites. We'll explore this pattern in more detail in Chapter 31, which is really more about design than about Python. As a quick example, though, we could use this composition idea to code our Manager extension by embedding a Person, instead of inheriting from it.
~ Unknown
BazillionQuotes.com
In Pythons 3.3 and 2.7, you can get help for a module you have not imported by quoting the module's name as a string — for example, help('re'), help('email.message') — but support for this and other modes may differ across Python versions.
~ Unknown
BazillionQuotes.com
remember that generator functions simply return objects with methods that handle next operations run by for loops at each level, and don't produce any results until iterated; and
~ Unknown
BazillionQuotes.com
Python programmers are able to write large OOP frameworks and applications without private declarations — an interesting finding about access controls in general that is beyond the scope of our purposes here.
~ Unknown
BazillionQuotes.com
