Table/issue 2868

This finishes up @cherti's original PR at #3055 by rebasing on master and updating to work on master.  I also fixed a few bugs and reformatted the code a bit.  After I submit this PR I'm probably going to rebase again to collapse down some of @cherti's original commits, but will still make sure they get credit.
Right, this can blow up when `self.format = ` is being set for the first time (unless we change `__new__` and the like to default `self._format` to `None`, or add it as a class attribute.  I agree that changing this to a `getattr(...)` would be fine too.