WARNING: This server provides a static reference view of the NetKernel documentation. Links to dynamic content do not work. For the best experience we recommend you install NetKernel and view the documentation in the live system .

Library Imports

Python on NetKernel is able to access libraries in the ROC address space.

Python code is completely at home on NetKernel. Effectively the Python runtime sees NetKernel as identical to a Unix operating system.

PYTHONPATH

res:/etc/PYTHONPATH may be specified in your address space. This resource must be a line delimited list of absolute resource path URIs which will be searched for Python packages.

For example to add the Python 2.7.0 library you would import urn:org:netkernel:lang:python:lib into your module address space and set the following entry in your res:/etc/PYTHONPATH resource...

//Path of the standard Python 2.7.0 Library resources 
res:/library/python/2.7.0/

The Python compiler will use the PYTHONPATH to resolve imports.

Comments

Lines beginning with # or // will be treated as comments.

Example

With a module set up to use the Python 2.5.0 library (as described above). The following standard Python provides an HTML formatted month...

from calendar import HTMLCalendar

c=HTMLCalendar(1)
t=c.formatmonth(2009, 8)

resp=context.createResponseFrom(t)
resp.setMimeType("text/html")

As you can see - this is just standard Python import from the 2.7.0 library.

Creating your own libraries

You can create your own libraries for Python on NetKernel. All that is necessary is that the directory location of your library specifies the file __init___.py