[IPython-user] Request for a magic function to hide private function in tab completion

Wong, Shin Guey shin.guey.wong@intel....
Fri May 22 22:44:33 CDT 2009


I just found from the Ipython reference doc that this feature already built-in in Ipython:

readline_omit__names: when tab-completion is enabled, hitting <tab> after a ‘.’ in a name will complete all attributes of an object, including all the special methods whose names include 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 ‘_’.

Regards,
Shin Guey

From: Wong, Shin Guey
Sent: Saturday, May 23, 2009 10:47 AM
To: 'Gökhan SEVER'
Cc: ipython-user@scipy.org
Subject: RE: [IPython-user] Request for a magic function to hide private function in tab completion

Hi Gökhan,

Thanks for the links. I should read the reference doc before asking this question ☹


For ur question, showing all the private functions is useful for developer. But I have some users who is only use IPython to do some simple stuff, when they hit tab and it shows all the private functions which shouldn’t call by them, this will be really confusing for them if they don’t have good understanding on python program. So, I am thinking to have a magic function that can turn on/off the private function in tab completion. So, a normal user can have a much cleaner tab completion to show all the functions they can call but not all the private function which shouldn’t call by them.<actually we do have another interactive python which has this feature but it is not compatible with IPython because it will crash with IPython tab completion>

Regards,
Shin Guey

From: Gökhan SEVER [mailto:gokhansever@gmail.com]
Sent: Friday, May 22, 2009 10:33 PM
To: Wong, Shin Guey
Cc: ipython-user@scipy.org
Subject: Re: [IPython-user] Request for a magic function to hide private function in tab completion

Wouldn't this be destructive to general use of the IPython?

Say we type 5 and a "." (dot) following 5 and hit tab all the helpers are in type of private. Of course this is just a simple example, who needs __mul__() while there is "*". I am sure many base types have only helpers of that type.

There is a section in IPython documentation regarding to defining your own magic functions. (Magic command system)
http://ipython.scipy.org/doc/nightly/html/interactive/reference.html

Gökhan
On Fri, May 22, 2009 at 5:03 AM, Wong, Shin Guey <shin.guey.wong@intel.com<mailto:shin.guey.wong@intel.com>> wrote:
Is it possible to add a magic function like %hideprivate so it will hide all private function in python code completion.

All the function name start with _ or __ like <__file__ , _name> will not show when user press <tab> completion.

Or maybe can somebody provide hint on:
1. how to add new magic function
2. how to modify the code completion

Regards,
Shin Guey
_______________________________________________
IPython-user mailing list
IPython-user@scipy.org<mailto:IPython-user@scipy.org>
http://mail.scipy.org/mailman/listinfo/ipython-user

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20090523/cf76a4d6/attachment-0001.html 


More information about the IPython-user mailing list