I didn't do it with a try block though for the reason that @hunse mentioned. It's not clear where the `AttributeError` came from, and could give very confusing results, if, say, `Network` doesn't have an initialized `_nextkey`. In order to use a try block you would have to do `method = network.generate_key` and then invoke the method later, but then it becomes more Pythonic to directly check if `network` has a `generate_key` method, which is precisely what `isinstance(network, Network)` does.

On the other side of things, this exists alongside all of the other checks in `__enter__` and `__exit__` to make the context stack fail faster. This is definitely the least important check, but it was also already being done indirectly before: https://github.com/ctn-waterloo/nengo/blob/e6059096f823b5adef24c0ebc53f6a10830f9edd/nengo/__init__.py#L44

I don't mind taking it out since, currently, it is pretty difficult to add non-Network objects to the stack.