##// END OF EJS Templates
Merge pull request #4083 from takluyver/better-hidden-ns...
Thomas Kluyver -
r12398:955056a0 merge
parent child Browse files
Show More
@@ -970,7 +970,7 b' class InteractiveShell(SingletonConfigurable):'
970
970
971 # A record of hidden variables we have added to the user namespace, so
971 # A record of hidden variables we have added to the user namespace, so
972 # we can list later only variables defined in actual interactive use.
972 # we can list later only variables defined in actual interactive use.
973 self.user_ns_hidden = set()
973 self.user_ns_hidden = {}
974
974
975 # Now that FakeModule produces a real module, we've run into a nasty
975 # Now that FakeModule produces a real module, we've run into a nasty
976 # problem: after script execution (via %run), the module where the user
976 # problem: after script execution (via %run), the module where the user
@@ -1150,7 +1150,7 b' class InteractiveShell(SingletonConfigurable):'
1150
1150
1151 Note that this does not include the displayhook, which also caches
1151 Note that this does not include the displayhook, which also caches
1152 objects from the output."""
1152 objects from the output."""
1153 return [self.user_ns, self.user_global_ns] + \
1153 return [self.user_ns, self.user_global_ns, self.user_ns_hidden] + \
1154 [m.__dict__ for m in self._main_mod_cache.values()]
1154 [m.__dict__ for m in self._main_mod_cache.values()]
1155
1155
1156 def reset(self, new_session=True):
1156 def reset(self, new_session=True):
@@ -1301,7 +1301,8 b' class InteractiveShell(SingletonConfigurable):'
1301 # And configure interactive visibility
1301 # And configure interactive visibility
1302 user_ns_hidden = self.user_ns_hidden
1302 user_ns_hidden = self.user_ns_hidden
1303 if interactive:
1303 if interactive:
1304 user_ns_hidden.difference_update(vdict)
1304 for name in vdict:
1305 user_ns_hidden.pop(name, None)
1305 else:
1306 else:
1306 user_ns_hidden.update(vdict)
1307 user_ns_hidden.update(vdict)
1307
1308
@@ -1321,7 +1322,7 b' class InteractiveShell(SingletonConfigurable):'
1321 for name, obj in variables.iteritems():
1322 for name, obj in variables.iteritems():
1322 if name in self.user_ns and self.user_ns[name] is obj:
1323 if name in self.user_ns and self.user_ns[name] is obj:
1323 del self.user_ns[name]
1324 del self.user_ns[name]
1324 self.user_ns_hidden.discard(name)
1325 self.user_ns_hidden.pop(name, None)
1325
1326
1326 #-------------------------------------------------------------------------
1327 #-------------------------------------------------------------------------
1327 # Things related to object introspection
1328 # Things related to object introspection
@@ -265,9 +265,10 b' class NamespaceMagics(Magics):'
265
265
266 user_ns = self.shell.user_ns
266 user_ns = self.shell.user_ns
267 user_ns_hidden = self.shell.user_ns_hidden
267 user_ns_hidden = self.shell.user_ns_hidden
268 nonmatching = object() # This can never be in user_ns
268 out = [ i for i in user_ns
269 out = [ i for i in user_ns
269 if not i.startswith('_') \
270 if not i.startswith('_') \
270 and not i in user_ns_hidden ]
271 and (user_ns[i] is not user_ns_hidden.get(i, nonmatching)) ]
271
272
272 typelist = parameter_s.split()
273 typelist = parameter_s.split()
273 if typelist:
274 if typelist:
General Comments 0
You need to be logged in to leave comments. Login now