[IPython-user] Disabling automatic parentheses feature?

Francesc Alted falted at pytables.org
Thu Sep 9 05:29:49 CDT 2004


Hi Fernando,

After some very quick and dirty introductory use of IPython to do
interactive graph work, I liked it so much that I'm getting hooked.

However, I have a small compatibility issue with the PyTables package. The
thing is that the standard python shell calls the repr() when you type an
object name on the console, i.e.:

>>> f.root.sqlite_small
/sqlite_small (Group) 'sqlite_small Group'
  children := ['search' (Group), 'create_standard' (Table), 'create_indexed' (Table)]

However, when one tries the same thing on ipython console, one gets:

In [6]: f.root.sqlite_small
------> f.root.sqlite_small()
Out[6]: <generator object at 0x406ffd2c>

so, ipython places autmagically the '()' after the object name, and this is
not what I want.

I've been pondering to eliminate the __call__ implementation of all the
PyTables objects to achieve better compatibility with IPython, but that
would lend to a backward incompatibility on existing PyTables programs.
However, I think now that it would be nice if IPython could provide some way
to not put the parenthesis if the object does not want to. 

For example, if the object has the next attribute:

_IPython__call__ = __repr__

then, it would mimic the behaviour of the standard console. Of course, the
default would be:

_IPython__call__ = __call__

so as to reproduce the current behavioour in IPython. That would open the
door to a more configurable behaviour for names typed alone at the IPython
prompt, and would save PyTables (and who knows if other packages) from
backward incompatibilities.

Cheers,

-- 
Francesc Alted




More information about the IPython-user mailing list