[IPython-dev] wildcard patch

Jörgen Stenarson jorgen.stenarson at bostream.nu
Sat Nov 12 06:38:07 EST 2005


I have discovered a problem with the wildcard functionality.

As it is written now it will only match attributes in an object that are
present in its __dict__, and only if there is no __dict__ for the object 
it builds one by calling dir(object). This means inherited attributes 
will not be visible for objects with a __dict__. Which means there will 
be a mismatch between the results you get using dir(object) compared to 

An example of this problem can be found by subclassing dict

In [1]:class test(dict):
    ...:    pass

In [2]:x=test(a=1)

In [3]:x
Out[3]:{'a': 1}

Without patch
In [4]:?x.*

With patch
In [4]:?x.*
+many more

The attached patch builds the namespace by calling dir on all objects,
this should make the wildcard search more consistent with dir. But the
operation of dir is not well specified and may change between releases 
of python. So if someone feels the operation of ?* should be more well 
defined I'm open to suggestions on how to go about that.


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: wildcard-patch-20051112
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20051112/61f11125/attachment.ksh>

More information about the IPython-dev mailing list