adds UserNSFormatter for falling back on shell.user_ns / builtins for name resolution.
allow access to user_ns in prompt_manager
I'm thinking rather than making UserNSFormatter take a shell object, instead we should have something like a MultiDictFormatter, whose constructor takes one or more dicts:
def __init__(self, *namespaces):
self.namespaces = namespaces
for container in self.namespaces:
then you simply initialize this guy with
self._formatter = MultiDictFormatter(shell.user_ns, __builtins__)
that way the object is generic and has less direct coupling to the specifics of our shell.
The only reason I didn't do that was that I wasn't 100% sure that shell.user_ns is a persistent object across %reset and the like.
Of course, if I instantiate the Formatter inside _render, then that wouldn't be an issue. It would just result in more instantiations, but I'm not sure that's more expensive than "string".format() anyway.
adds UserNSFormatter for falling back on shell.user_ns / builtins for
Closes #1151, rebased to prevent recursive merge.