In python, you can type dir() to get a list of the items in the global namespace, but the list is ugly, and it includes both public and private objects. I want to write a function (say pretty) that pretties it up. My function will live inside a module.
When I call pretty(dir()) I wind up pretty printing the objects in the module. Same for pretty(sorted(globals())). How can I get the list of the names of the objects in the global namespace (from within a module), so I can do my beautification?
I'm working in python3, if that matters.
EDIT:
The first two answers that came back had to do with my controlling code in the module containing pretty. That's not what I want to do. I'm aiming at an experience like the following.
>>> foo = create_something()
>>> bar = create_something_else()
>>> create_lots_more_stuff()
>>> # Hmmmm I'd like to see a list of all the things I have created in my interactive python session.
>>> pretty(dir())
foo bar
baz qux
etc etc_etc
globals()gives you the global namespace, which is the objects in the module