Eduard Lebedyuk · Jan 16, 2020 2m read
Python Gateway VI: Jupyter Notebook

This series of articles would cover Python Gateway for InterSystems Data Platforms. Execute Python code and more from InterSystems IRIS. This project brings you the power of Python right into your InterSystems IRIS environment:

  • Execute arbitrary Python code
  • Seamlessly transfer data from InterSystems IRIS into Python
  • Build intelligent Interoperability business processes with Python Interoperability Adapter
  • Save, examine, modify and restore Python context from InterSystems IRIS

Other articles

The plan for the series so far (subject to change).


The Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and narrative text.

This extension allows you to browse and edit InterSystems IRIS BPL processes as jupyter notebooks.

0 0 312

How do I rename class programmatically?

This discussion touches on data move which, is not a concern in my case (BPL renames).

I also don't care about external references.

The best I got is:

  1. Get class text as string
  2. Replace class name in this string
  3. Save new string as new class
  4. Open new class as object
  5. Delete storage
  6. Compile class

Are there any better alternatives?

0 5 216

I need to know if given package exists or not.

Currently found two solution - one doesn't work, another works but I don't like it.


Solution 1.

I started, of course, with %Dictionary package - it has PackageDefinition class after all.

However, %ExistsId returned 0 on packages that clearly do exist, so I went to %LoadData, it uses this macro to determine if the package exist:

0 10 137

Is there a way to get dynamic object from iterator?

set arr=[1,2,3]
set iter=arr.%GetIterator()

I pass iterator several frames down and I'd rather avoid passing both the array and iterator, but for debugging I need to access original object in a situation where only iterator is available.

Is there a way to do it?

0 5 195
Eduard Lebedyuk · Jan 13, 2020 1m read
Difference between while and for

While and for are pretty similar, but sometimes you need to do a not recommended thing - change cycle boundaries.

In this situation while and for are different. For calculates boundaries once per run and while calculates boundaries on every iteration.

Consider this code sample:

set x = 5
for i=1:1:x {
     write "i: ", i,", x: ", x,!
     set x = x+1

You'll get this output:

0 7 243
Eduard Lebedyuk · Dec 9, 2019 1m read
ÍàØâàÞæØâë and you

If you work with anything other than English, you would earlier or later encounter the characters from the title or just plain ??????????.

Encodings are usually known, but sometimes you just get gibberish and need to make sense of it.

In this cases $zcvt is your friend, the three argument form specifically.

But there are a lot of options. So here's an utility script to check how the text would look like in different encodings:

0 4 268
Eduard Lebedyuk · Dec 7, 2019 1m read
About %objlasterror

%objlasterror is a useful reference to the last error.

Every time $$$ERROR is called, %objlasterror is set to a result of this call.

It's important in cases where you want to convert exception to status:

Try {
   //  quality code
} Catch ex {
   Set sc = $g(%objlasterror, $$$OK)
   Set sc = $$$ADDSC(sc, ex.AsStatus())

Because AsStatus calls $$$ERROR under the wraps, the order is important, first you need to get %objlasterror and  convert exception after that.

1 3 345