Hi,i wonder if there is an editor or ide that has similar dinamic
instrospection features as ipython? ,since i have failed to find one, i
spend more time coding in ipython than in my editor.
Well the feature i need the most is tab introspection since python has so
many libraries and functions that is imposible to remember all of them.For
example when i type urllib2.<tab> i get:
urllib2.Abstrac tBasicAuthHandl er urllib2.__class __
urllib2.mimetoo ls
urllib2.Abstrac tDigestAuthHand ler urllib2.__delat tr__
urllib2.mimetyp es
urllib2.Abstrac tHTTPHandler urllib2.__dict_ _
urllib2.noheade rs
urllib2.BaseHan dler urllib2.__doc__
urllib2.os
urllib2.CacheFT PHandler urllib2.__file_ _
urllib2.parse_h ttp_list
urllib2.CustomP roxy urllib2.__getat tribute__
urllib2.parse_k eqv_list
<skip>..
I also made a function that gives me a quickly overview of an objects,for
example when i type h(urllib2) i get :
AbstractBasicAu thHandler <c> : Non
AbstractDigestA uthHandler <c> : Non
AbstractHTTPHan dler <c> : Non
BaseHandler <c> : Non
CacheFTPHandler <c> : Non
CustomProxy <c> : Non
CustomProxyHand ler <c> : Non
socket <m> : This module provides socket operations and some related
splitattr <f> : splitattr('/path;attr1=valu e1;attr2=value2 ;...') ->
splitgophertype <f> : splitgophertype ('/Xselector') --> 'X', 'selector'
splithost <f> : splithost('//host[:port]/path') --> 'host[:port]', '/path'
splitpasswd <f> : splitpasswd('us er:passwd') -> 'user', 'passwd'
splitport <f> : splitport('host :port') --> 'host', 'port'
splitquery <f> : splitquery('/path?query') --> '/path', 'query'
splittype <f> : splittype('type :opaquestring') --> 'type', 'opaquestring'
splituser <f> : splituser('user[:passwd]@host[:port]') --> 'user[:passwd]',
unquote <f> : unquote('abc%20 def') -> 'abc def'
unwrap <f> : unwrap('<URL:ty pe://host/path>') --> 'type://host/path'
url2pathname <f> : Non
urlopen <f> : Non
urlparse <m>
Well,i would like similar functionality in the enviroment that i am coding
in, i hate having to go to the interactive shell every 7 seconds to type
'h(<class name>)' for example.
The code for my help function (is sucky since i have had so much trouble
finding the types of some objects and doesnt work for some modules):
import sgmllib
import types
def h(name,display= 'all',allow_her encia=False):
'''name-> any object name that is not an instance(module ,attr,func)
display-> all | m | f | c | a ie : m = module
allow_Herencia True | False
Display object's information for a quick overview
'''
if allow_herencia == True : iter = dir(name)
else :
iter = name.__dict__.k eys()
iter.sort()
for x in iter:
attr = getattr(name,x)
try: ## can be better with hasattr() builtin
doc = str(attr.__doc_ _)
except:
print ' %s %s' % (x,attr)
continue
else :
limit = doc.find('\n')
doc = doc[:limit]
membertype = __gettype(attr)
if display is membertype or display is 'all': print ' %s <%s> : %s'
% (x,membertype,d oc)
def __gettype(attr) :
## needs reworking
t = type(attr)
#print t
if t is types.ModuleTyp e : return 'm'
elif t is type(str.isuppe r) or\
t is types.BuiltinFu nctionType or\
t is types.FunctionT ype or\
t is types.UnboundMe thodType or\
t is '<type \'instancemetho d\'>' :
return 'f'
elif t is type(str.__eq__ ) : return 'w' #wraper
elif t is types.TypeType or t is type(sgmllib.SG MLParser): return 'c'
else: return 'a'