[IPython-user] Re: ipython as zope interactive console
Fernando Perez
Fernando.Perez at colorado.edu
Tue Oct 5 15:57:41 CDT 2004
Jeff Kowalczyk schrieb:
> Fernando Perez wrote:
>
>>>- Zope objects have *lots* of attributes! Any tips available for using
>>>the code-completion and attribute exploration with massive lists of
>>>attributes would probably help Zope newbies immensely.
>>
>>Mmh. I've run into the same problem with VTK objects, which also have
>>monster attribute lists. My approach is just to type obj.A<TAB>,
>>obj.B<TAB>, etc: typing first a letter or two to narrow down the size of
>>the completion list. Not ideal, I know...
>
>
> Do you have any tricks to view code completion only for attributes which
> do not start with '_' (public attributes)
Yes, see in ~/.ipython/ipythonrc:
# iii. readline_omit__names: normally hitting <tab> after a '.' in a name will
# complete all attributes of an object, including all the special methods
# whose names inlclude double underscores (like __getitem__ or __class__). If
# you'd rather not see these names by default, you can set this option to
# 1. Note that even when this option is set, you can still see those names by
# explicitly typing a _ after the period and hitting <tab>: 'name._<tab>' will
# always complete attribute names starting with '_'.
# This option is off by default so that new users see all attributes of any
# objects they are dealing with.
readline_omit__names 1
Just set this to 1 in your config, and you'll only see public names.
> Is there any way to view code completion only for defined attributes of
> the object, not those it inherits from the acquisition environment (if
> that's the right term)? Object.__dict__ usually gives an attribute list
> that's close to the API, can that be linked to code completion?
>
> It would be cool to be able to alternate between code-completing in
> __dict__ or the acquisition environment based on some easily applied trick
> or magic syntax. Perhaps Object.(tab) -> __dict__ and
> Object..(tab) -> acquisition, with the second . stripped from the next
> input prompt. Maybe Object...(tab) could search both, bringing the
> whole huge attribute list into play.
I'm not really sure what the 'acquisition environment' means. Something like
this goes beyond what normal ipython can do, since it's obviously a
zope-specific thing. However, you could certainly extend the ipython
completion mechanism by inheriting from MagicCompleter in IPython.iplib, and
then have a zope profile which implements these enhancements in the context of
zope debugging. That's the whole point of ipython: it exposes pretty much all
of its internals for problem-specific customization, and choosing these
customizations is trivial with a profile:
ipython -p zope
could load your fancy, zope-enhanced completer into ipython while a simple
ipython
would give you the plain vanilla version.
I hope this helps,
f
More information about the IPython-user
mailing list