· Jun 19, 2023

How do I use $znspace and Other $Functions and $Variables in Embedded Python?

Hi folks!

Just curious, how can I use $znspace in embedded python code?

How does other $functions work, e.g. $zv, $job, etc

Product version: IRIS 2023.1
Discussion (7)2
Log in or sign up to continue

After a bit of digging I came up with the following equivalents.


>>> iris.cls("%SYSTEM.SYS").Horolog()

Equivalent access:

>>> var=iris.cls("%Library.UTC").NowLocal()
>>> var
'2023-06-22 23:50:04.386'
>>> iris.cls("%Library.UTC").ConvertTimeStampToHorolog(var)


>>> iris.cls("%SYSTEM.SYS").NameSpace()

ZN [Namespace] - aka change namespace

Keep your object fingers in the car at all times!!

Any created object script references need to be cleared BEFORE changing back. Is it necessary.

>>> iris.cls("%SYSTEM.Process").SetNamespace("%SYS")


>>> iris.cls("%SYSTEM.SYS").ProcessID()

$SYSTEM - Instance name

>>> iris.cls("%SYS.System").GetInstanceName()

But you might have same name on different operating system / container so:

>>> iris.cls("%SYS.System").GetUniqueInstanceName()


>>> iris.cls("%SYSTEM.SYS").TimeStamp()

$ZTIMEZONE – Contains the time zone offset from the Greenwich meridian

>>> iris.cls("%SYSTEM.SYS").TimeZone()

$ZVERSION – Contains a string describing the current version of InterSystems IRIS

>>> iris.cls("%SYSTEM.Version").Format(0)
'IRIS for Windows (x86-64) 202x.x.0 (Build xxU) Thu xx 2023 06:22:16 EDT'

Hi Evgeny,

Not saying this is best way but this indirection can be achieved with python eval. For example:

$Classmethod equivalent


$Property equivalent

Instantiating a Python exception and then iterate over properties printing out:


for propertyname in ["Name","Code","Data","Location"]:

    print(f"Property Name {propertyname} has value {propvalue}\n")

output was:

Property Name Name has value MyOops
Property Name Code has value 123
Property Name Data has value SomeData
Property Name Location has value def+123^XYZ