Skip to content

q Context Interface

This page documents the interface used for accessing q contexts/namespaces.

pykx.ctx

The context interface provides an easy to way access q contexts (also known as namespaces when at the top level). For more information about contexts/namespaces in q please refer to Chapter 12 of Q for Mortals.

CurrentDirectory

CurrentDirectory()

Bases: type(Path())

pathlib.Path instance for the current directory regardless of directory changes.

QContext

QContext(q, name, parent, no_ctx=False)

Interface to a q context.

Members of the context be accessed as if the QContext object was a dictionary, or by dotting off of the QContext object.

Parameters:

Name Type Description Default
q Q

The q instance in which the context exists.

required
name str

The name of the context.

required
parent QContext

The parent context as a QContext, or None in the case of the global context.

required

_invalidate_cache

_invalidate_cache()

Clears the cached context, forcing it to be reloaded the next time it is accessed.

ZContext

ZContext(global_context)

Bases: QContext

Special interface to handle the .z context.

The .z context in q is not a normal context; it lacks a dictionary. To access it users must access its attributes directly.

_fully_qualified_name

_fully_qualified_name(name, parent)

Constructs the fully qualified name of a context given its name and parent.