Learning Python 5th edition (ebook) by David Ascher and Mark Lutz

I’ll start by saying this is a massive book, covering so many things that’s hard to go through it cover-to-cover without forgetting or missing out on stuff. Overall the book is excellent but we always need to keep in mind it’s “the book over Python” so no matter how big it is, it will always skimp on something.

Rating 4/5 - just of its sheer size, otherwise an excellent book

Chapter1-4

Chapter 5

Chapter 6

Chapter 7 - Strings

Chapter 8 - Lists and dictionaries

Chapter 9 - tuples, files, …

Chapter 10-13

Chapter 14-17 - Iterators, Scope, …

Chapter 18 - Arguments

Chapter 22-25 - Modules/Packages/Advanced Modules

Chapter 26: OOP

Chapter 30-31: operator overloading and oop techniques

def __attrnames(self):
 result = ""
 for attr in sorted(self.__dict__):
    result += "\t%s=%s\n" % (attr,self.__dict__[attr])
 return result
def __str__(self):
    return "Instance of %s, address %s: %s" %  (self.__class__.__name__,id(self),self.__attrnames())

Ch 32: advanced class topics

class P():
   def getage(self): return 22
   def setage(self, new_age): self._age = new_age
   age = property(getage, setage, None, None)
Exceptions (ch 34 & ch 35 & ch 36)
try:
    # ...run program...
except:                         # All uncaught exceptions come here
    import sys
    print('uncaught!', sys.exc_info()[0], sys.exc_info()[1])

Unicode and bytestrings - ch 37

Managed attributes - ch 38

@property
def address(self):
    return self._address
@address.setter
@def address(self, value):
    self._address = value

Decorators - ch 39

class tracer:
    def __init__(self, func):
        self.calls = 0
        self.func = func
    def __call__(self, *args):  # On @ decoration: save original func
        self.calls += 1         # On later calls: run original func
        print('call %s to %s' % (self.calls, self.func.__name__))
        self.func(*args)
        #[...]
@tracer
def spam(a, b, c):
print(a + b + c)         # spam = tracer(spam) # Wraps spam in a decorator object

Metaclasses - ch 40