[IPython-dev] Mathematica wildcards in ?

Fernando Perez Fernando.Perez at colorado.edu
Fri Sep 9 17:49:54 CDT 2005


Hi Jörgen,

Jörgen Stenarson wrote:
> Hi all,
> 
> I'm a happy user of IPython but I often wish I had a feature found in 
> Mathematica. Where the ? command can take wildcards and then produce a 
> list of all names matching the wildcard. There is also support for 
> matching down in packages.
> 
> example when using pylab:
> ?pl*
> ['plot', 'plot_date', 'plotting']

[...]

> I have appended a first shot at an implementation of this feature. It 
> should work by starting ipython and then importing wildcard.
> 
> The functionality is installed as a magic function named %listdef. This 
> seemed like the easiest way to test it.
> 
> Is this something more people would find useful added to the ? function?

I think this is _excellent_ functionality, and I'd be happy to include it in a 
future release.  A few comments about your implementation, so we can fine-tune 
it (though it's already useful as is) for inclusion:

- please refrain from using python 2.4-specific features.  For example, 
instead of sorted(foo), use the slower foo1=list(foo);foo1.sort().  I try hard 
to maintain with the current release series compatibility with python 2.2, 
since there is still a sizeable userbase on that platform.  The new ipython 
development branch:

http://projects.scipy.org/ipython/ipython/browser/ipython/branches/chainsaw

is 2.4-only, but for the release branch I'm sticking to 2.2.  While more 
verbose and less convenient, it's still possible to implement this 
functionality in a 2.2-valid way (note that genutils provides some 
compatibility symbols from 2.3, so you can mostly code to 2.3, and stick a 2.2 
version of the feature in the compatibility section there).

- It would be excellent if you could also scan the builtin namespace, so that 
this could be used by new users to learn about builtins.  Currently you only 
scan the user namespace.

- The OInspect module has already a fair amount of functionality that you can 
perhaps rely on, if you need it.  Also have a look at _ofind in Magic.py.  I'm 
not 100% sure, but I just suggest them as potentially useful in terms of 
reducing code duplication.

- Code formatting: it would be best if you could please conform to 
left-indented docstrings like the rest of ipython does (this follows Python 
style PEP directives).  For reference, I've put up some basic guidelines for 
ipython contributors here:

http://projects.scipy.org/ipython/ipython/wiki/DeveloperGuidelines


But I'm _very_ interested in this!  I am planning on cutting an ipython 
release in the next couple of weeks with some bugfixes which have accumulated, 
so if you get a chance to work on this, I'll be happy to include it.  This 
kind of functionality has been asked for _many_ times in the past.

Best regards,

f.




More information about the IPython-dev mailing list