So I wanted to do my taxes. I wrote a 'tax2003' Python module containing a bunch of stuff like this:
class employer1: earnings = 12345.67 federal_wh = 1234.56 class employer2: earnings = 123456.78 federal_wh = 12345.67 class form1040: # income wages = employer1.earnings + employer2.earnings business_income = scheduleC.net_profit total_income = wages + business_income # ... assert line39 > 103000 taxable_income = max(line39 - line40, 0) # ... # payments federal_wh = employer1.federal_wh + employer2.federal_wh amount_owed = total_tax - total_payments etc. When I imported this module, I could inspect things like form1040.amount_owed; I did this interactively with Emacs's python-mode, which let me just C-c RET to reimport the module; then I could look at the values of variables. When I was done, though, I wanted to get a printout of all these values (so I could fill out the actual forms, and also so I could find any errors I'd made) and delete this module so I could put my computer back online. So I wrote this function to print out all the amounts: import types def listmod(module, name=None): if name is None: name = module.__name__ if type(module) in (type(''), type(1), type(1.2)): print "%s = %s" % (name, module) else: for subname in dir(module): if subname[:2] == '__': continue obj = getattr(module, subname) if type(obj) is type(types): continue # no submodules! listmod(obj, name + '.' + subname) Then I ran listmod.listmod(tax2003) and got output like: tax2003.employer1.earnings = 12345.67 tax2003.employer1.federal_wh = 1234.56 ... tax2003.form1040.tax = 22032532 tax2003.form1040.amount_owed = 22030403.8215375 It's not TurboTax, but it keeps me from making any arithmetic errors.