Didn’t test after adding the has option. This version tested better.
from pprint import pprint as pp
builtins.pp = pp
del pp
def ns(obj=None, startswith=‘’, endswith=‘’, notstarts=‘‘, notends=’’, has=‘’):
“”"
Nice example usage: ns(wx, ‘EVT_’, has=‘COMMAND’)
dir() equivelent ns(None, ‘', '’, ‘’, ‘’)
“”"
if obj:
for i in dir(obj):
if not notstarts == ‘’ and i.startswith(notstarts): continue
if not notends == ‘’ and i.endswith(notends): continue
if not startswith == ‘’ and not i.startswith(startswith): continue
if not endswith == ‘’ and not i.endswith(endswith): continue
if not has == ‘’ and not has in i: continue
print(i)
else:
for i in sorted(globals().keys()):
if not notstarts == ‘’ and i.startswith(notstarts): continue
if not notends == ‘’ and i.endswith(notends): continue
if not startswith == ‘’ and not i.startswith(startswith): continue
if not endswith == ‘’ and not i.endswith(endswith): continue
if not has == ‘’ and not has in i: continue
print(i)
builtins.ns = ns
del ns
builtins.clear = slicesshell.clear
builtins.shell = slicesshell
import wx
builtins.wxapp = wx.GetApp()
del slicesshell
del wx
print(‘Commands: ls, sx, run, clear, shell, ns’)
print( dir() )
···
On Wed, Jul 3, 2013 at 2:37 AM, DevPlayer devplayer@gmail.com wrote:
from pprint import pprint as pp
builtins.pp = pp
del pp
def ns(obj=None, startswith=‘’, endswith=‘’, notstarts=‘‘, notends=’’, has=‘’):
“”"
Nice example usage: ns(wx, ‘EVT_’, has=‘COMMAND’)
dir() equivelent ns(None, ‘', '’, ‘’, ‘’)
“”"
if obj:
for i in dir(obj):
#if i.startswith(notstarts) and i.endswith(notends): continue
if notstarts and notends are defined
then skip key if key has notstart OR notends
if not notstarts == ‘’ and not notends == ‘’ and i.startswith(notstarts) and i.endswith(notends): continue
if startswith and endswith are defined and key has
either startswith or endswith print it
if startswith and endswith and i.startswith(startswith) and i.endswith(endswith) and has in i:
#if notstarts and i.startswith(notstarts): continue
print(i)
continue
else:
else startswith and endswith are not defined; so print it
print(i)
else:
for i in sorted(globals().keys()):
if notstarts and notends are defined
then skip key if key has notstart OR notends
if not notstarts == ‘’ and not notends == ‘’ and i.startswith(notstarts) and i.endswith(notends): continue
if startswith and endswith are defined and key has
either startswith or endswith print it
if startswith and endswith and i.startswith(startswith) and i.endswith(endswith) and has in i:
print(i)
continue
else:
else startswith and endswith are not defined; so print it
print(i)
builtins.ns = ns
del ns
builtins.clear = slicesshell.clear
builtins.shell = slicesshell
import wx
builtins.wxapp = wx.GetApp()
del slicesshell
del wx
print(‘Commands: ls, sx, run, clear, shell, ns’)
print( dir() )
–
You received this message because you are subscribed to the Google Groups “wxPython-users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.