This would be better as:
```
def diff(cube_a, cube_b, string_io=None):
```
Then it would use whatever sys.stdout happened to be when it was called, rather than what sys.stdout happened to be when the function was first defined.