Nice pysliceshell startup script

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.

I don’t get it why you ‘del pp’ and ‘del ns’ right after ‘builtins.pp = pp’ and ‘builtins.ns = ns’. What’s the reason for 'del’ing the object?

I didn’t want them in the global namespace. I wanted to hide them like the other sliceshell functions.

···

On Wed, Jul 3, 2013 at 3:17 AM, Boštjan Mejak mejak.bost@gmail.com wrote:

I don’t get it why you ‘del pp’ and ‘del ns’ right after ‘builtins.pp = pp’ and ‘builtins.ns = ns’. What’s the reason for 'del’ing the object?

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.

to clarify, del ns deletes from the global namespace, not the builtins namespace

···

On Wed, Jul 3, 2013 at 3:27 AM, Dev Player devplayer@gmail.com wrote:

I didn’t want them in the global namespace. I wanted to hide them like the other sliceshell functions.

On Wed, Jul 3, 2013 at 3:17 AM, Boštjan Mejak mejak.bost@gmail.com wrote:

I don’t get it why you ‘del pp’ and ‘del ns’ right after ‘builtins.pp = pp’ and ‘builtins.ns = ns’. What’s the reason for 'del’ing the object?

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.

“del” doesn’t delete an object.� “del” just removes a name from a
namespace.� If the object that name was bound to has no other
references, the the object will eventually be deleted, but that’s
more or less a side effect.

···

Bo�tjan Mejak wrote:

    I don't get it why you 'del pp' and 'del ns' right

after ‘builtins.pp = pp’ and ‘builtins.ns = ns’. What’s
the reason for 'del’ing the object?

-- Tim Roberts, Providenza & Boekelheide, Inc.

timr@probo.com