Namespace tab

The Namespace tab, displayed in figure 4.8, is split into two parts, again using the wx.SplitterWindow control. The left-hand side contains a tree control that displays the current namespace, while the right-hand side displays details about the object currently selected in the namespace tree.

PyCrust

File Edit Options Help

1 PyCrust 0.9.4 - The Flakiest Python She LI

2 Sponsored by Orbtech - Your source for Python programming expertise.

4l [GCC 3.2.2 (Mandrake Linux 9.1 3.2. 2-3mdk) ] on linux2

5 Type "help", "copyright", "credits" or "license" for more information.

sl ['_built ins_', '_doc_', '_file_', '_name_', "filling", 'notebook'.

I EHE

Namespace Display Calltip Session Dispatcher

_-_getattribute_

Value: <module 'wx' from '/home/pobrien/Code/wx/_init_. pyc'>

Source Code:

# Purpose:

# Created:

# Copyright:

# Licence:

The presence of this file turns this directory into a Python package.

Robin Dunn

8-Aug-1998

(c) 1998 by Total Control Software wxWindows license import _version_

version = version .VERSION STRING

# Load the package namespace with the core classes and such

PyCrust 0.9.4 - The Flakiest Python Shell, Sponsored by Orbtech - Your source for Python programming expertise.

Figure 4.8 PyCrust's namespace tree allows one to drill down into objects and inspect their attributes

The namespace tree presents a hierarchical view of all the objects in the current namespace. These are the items that would be returned if you ran the locals() built-in Python function. In figure 4.8, we've imported the wx package and selected it in the namespace tree. The right-hand side displays the name of the selected item, its type, and its current value. If the object has source code associated with it, PyCrust displays that also. In this case, wx is a wxPython package, so PyCrust displays the source code from the__init__.py file that resides in the wx directory.

The first line of the display provides a fully qualified object name that you can cut and paste into the PyCrust shell or into your application source code. For example, if you import the locale module and drill down into it you can reach the items stored within an encoding_alias dictionary attribute of the locale module. Once you select one of these items, you can cut and paste its displayed name directly into the PyCrust shell, as in the following:

'ISO8859-1'

In this case, PyCrust provided us with a fully qualified name (locale. encoding_alias['en']) that used Python's index notation (['en']) to reference the specified item in the encoding_alias dictionary. This mechanism also works for lists. If you find something in the namespace tree that you want to reference in your code, PyCrust gives you the exact syntax to fulfill the task.

Was this article helpful?

0 0

Post a comment