""" chaining.py An example of "chaining" method calls one after the other. The idea is that if a method returns the same object, then you can call another method on the result. $ python >>> from chaining import * >>> c = ChainThing() >>> c.increment().double().increment(3).double() >>> c.x 5 """ class ChainThing(object): """ demo in class """ def __init__(self, x=0): """ """ self.x = x def double(self): self.x = 2 * self.x return self def increment(self, inc=1): self.x = self.x + inc return self