Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Add iPython Tab completion on module loading

  • Loading branch information...
1 parent aea76b8 commit a996292238ab98dcf53f2d48476d637eab9f1a72 @piti118 committed
Showing with 17 additions and 0 deletions.
  1. +17 −0 numpy/core/
17 numpy/core/
@@ -804,3 +804,20 @@ def array(obj, dtype=None, shape=None, offset=0, strides=None, formats=None,
if issubclass(res.dtype.type, nt.void):
res.dtype = sb.dtype((record, res.dtype))
return res
+def install_ipython_completers():
+ """Register the recarray type with IPython's tab completion machinery, so
+ that it knows about accessing column names as attributes."""
+ from IPython.utils.generics import complete_object
+ @complete_object.when_type(recarray)
+ def complete_recarray_colname(obj, prev_completions):
+ return prev_completions + list(obj.dtype.names)
+# Importing IPython brings in about 200 modules, so we want to avoid it unless
+# we're in IPython (when those modules are loaded anyway).
+if "IPython" in sys.modules:
+ try:
+ install_ipython_completers()
+ except Exception:
+ pass

0 comments on commit a996292

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