Where can I find .join() in the docs

Geiger Ho s997659 at ee.cuhk.edu.hk
Fri May 31 00:12:54 EDT 2002


Hi all,

  I would like to know how could I modify the following code so that it
can be a function in a module? I've tried. But the interpreter warns me
that no __dic__ attribute in __builtins__.

  Also, how can I know how many namespaces I create in an environment and
how can I modify the code so that it can show what is in a specific
namespace.

  Thanks in advance.

Regards,
Geiger


On Thu, 30 May 2002, Duncan Booth wrote:

> You might find this useful as it shows you what is really in builtins, not 
> what is documented:
> >>> def showNamespace(namespace=None):
>         '''Summarise namespace contents'''
>         if namespace is None: namespace = __builtins__.__dict__
>         names = {}
>         # Build a dictionary mapping type to list of names
>         for k, v in namespace.items():
>             names.setdefault(type(v), []).append(k)
>         # Extract typename and name lists into a list
>         items = [(t.__name__, v) for t, v in names.items()]
>         items.sort() # Sort by typename
>         # Print out the variables categorised by type
>         for k, v in items:
>             print "%s:" % k, ", ".join(v)
>             print
>




More information about the Python-list mailing list