Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix wildcard search for new namespace model.

Closes gh-1076
  • Loading branch information...
commit 6376dd8c122787615ac3fa2b3a37533d8e5d2f10 1 parent 9a82f22
Thomas Kluyver authored December 01, 2011
2  IPython/core/interactiveshell.py
@@ -923,7 +923,7 @@ def init_create_namespaces(self, user_module=None, user_ns=None):
923 923
         # A table holding all the namespaces IPython deals with, so that
924 924
         # introspection facilities can search easily.
925 925
         self.ns_table = {'user_global':self.user_module.__dict__,
926  
-                         'user_local':user_ns,
  926
+                         'user_local':self.user_ns,
927 927
                          'builtin':builtin_mod.__dict__
928 928
                          }
929 929
     
2  IPython/core/magic.py
@@ -693,7 +693,7 @@ def magic_psearch(self, parameter_s=''):
693 693
             return
694 694
 
695 695
         # default namespaces to be searched
696  
-        def_search = ['user','builtin']
  696
+        def_search = ['user_local', 'user_global', 'builtin']
697 697
 
698 698
         # Process options/args
699 699
         opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
18  IPython/core/oinspect.py
@@ -762,13 +762,15 @@ def psearch(self,pattern,ns_table,ns_search=[],
762 762
                                  (name,ns_table.keys()))
763 763
 
764 764
         #print 'type_pattern:',type_pattern # dbg
765  
-        search_result = []
  765
+        search_result, namespaces_seen = set(), set()
766 766
         for ns_name in ns_search:
767 767
             ns = ns_table[ns_name]
768  
-            tmp_res = list(list_namespace(ns,type_pattern,filter,
769  
-                                          ignore_case=ignore_case,
770  
-                                          show_all=show_all))
771  
-            search_result.extend(tmp_res)
772  
-        search_result.sort()
773  
-
774  
-        page.page('\n'.join(search_result))
  768
+            # Normally, locals and globals are the same, so we just check one.
  769
+            if id(ns) in namespaces_seen:
  770
+                continue
  771
+            namespaces_seen.add(id(ns))
  772
+            tmp_res = list_namespace(ns, type_pattern, filter,
  773
+                                    ignore_case=ignore_case, show_all=show_all)
  774
+            search_result.update(tmp_res)
  775
+
  776
+        page.page('\n'.join(sorted(search_result)))

0 notes on commit 6376dd8

Please sign in to comment.
Something went wrong with that request. Please try again.