Goodreads helps you follow your favorite authors. Be the first to learn about new releases!
Start by following Mark Lutz.

Mark Lutz Mark Lutz > Quotes

 

 (?)
Quotes are added by the Goodreads community and are not verified by Goodreads. (Learn more)
Showing 1-30 of 115
“As usual, though, if you find yourself running into a wall, stop running into a wall!”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“The problem here is a very general one: anytime you copy code with cut and paste, you essentially double your maintenance effort in the future.”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“Factories can be a major undertaking in a strongly typed language such as C++ but are almost trivial to implement in Python.”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“To minimize the chances of name collisions like this, Python programmers often prefix methods not meant for external use with a single underscore: _gatherAttrs in our case.”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“Technically, instance creation first triggers the __new__ method, which creates and returns the new instance object, which is then passed into __init__ for initialization.”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“Assignments to instance attributes create or change the names in the instance, rather than in the shared class. More generally, inheritance searches occur only on attribute references, not on assignment:”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“The more important point here is that this Manager alternative is representative of a general coding pattern usually known as delegation — a composite-based structure that manages a wrapped object and propagates method calls to it.”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“operator overloading — coding methods in a class that intercept and process built-in operations when run on the class’s instances.”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“Inheritance is best at coding extensions based on direct customization (like our Manager specialization of Person). Composition is well suited to scenarios where multiple objects are aggregated into a whole and directed by a controller layer class. Inheritance passes calls up to reuse, and composition passes down to delegate.”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“Technically, __str__ is preferred by print and str, and __repr__ is used as a fallback for these roles and in all other contexts.”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“The name used as the assignment target in a for header line is usually a (possibly new) variable in the scope where the for statement is coded. There’s not much unique about this name; it can even be changed inside the loop’s body, but it will automatically be set to the next item in the sequence when control returns to the top of the loop again.”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“In fact, type itself derives from object, and object derives from type, even though the two are different objects — a circular relationship that caps the object model and stems from the fact that types are classes that generate classes:”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“Although we can store functions in dictionaries, too, using them to process implied instances is nowhere near as natural and structured as it is in classes.”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“Design note: as we’ll learn in Chapter 30, the __repr__ method is often used to provide an as-code low-level display of an object when present, and __str__ is reserved for more user-friendly informational displays like ours here.”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“Operator overloading is coded in a Python class with specially named methods; they all begin and end with double underscores to make them unique. These are not built-in or reserved names; Python just runs them automatically when an instance appears in the corresponding operation.”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“Assignments to instance attributes create or change the names in the instance, rather than in the shared class.”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“In a sense, a module is like a single-instance class, without inheritance, which corresponds to an entire file of code.”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“ZODB, for example, is similar to Python’s shelve but addresses many of its limitations, better supporting larger databases, concurrent updates, transaction processing, and automatic write-through on in-memory changes (shelves can cache objects and flush to disk at close time with their writeback option, but this has limitations: see other resources).”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“Third, and perhaps most subtle, the display methods also have the potential to trigger infinite recursion loops in rare contexts — because some objects’ displays include displays of other objects, it’s not impossible that a display may trigger a display of an object being displayed, and thus loop. This is rare and obscure enough to skip here, but watch for an example of this looping potential to appear for these methods in a note near the end of the next chapter in its listinherited.py example’s class, where __repr__ can loop.”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“that’s why we need recursion here: the number of nested loops is arbitrary, and depends on the length of the sequence permuted:”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“Class attributes can also be created, though, by assigning attributes to the class anywhere a reference to the class object exists — even outside the class statement.”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“Python’s super is like a box of chocolates — you never know what you’re going to get!”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“Boolean and and or operators return a true or false object in Python, not the values True or False.”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“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.”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“pdb also includes a postmortem function (pdb.pm()) that you can run after an exception occurs, to get information from the time of the error. See”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“One of the first questions that bewildered beginners often ask is: how do I find information on all the built-in tools?”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“you can do everything in Python that you can in Perl, but”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“a raw string cannot end in an odd number of backslashes.”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“In other words, the age-old acronym KISS still applies: Keep It Simple — followed either by a word that is today too sexist (Sir), or another that is too colorful for a family-oriented book like this...”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming
“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.”
Mark Lutz, Learning Python: Powerful Object-Oriented Programming

« previous 1 3 4
All Quotes | Add A Quote
Learning Python Learning Python
3,212 ratings
Open Preview
Programming Python Programming Python
1,081 ratings
Open Preview