
This will be a short article about PEP 8, the Python style guide.
What is PEP 8?
In a nutshell, PEP 8 provides guidelines and best practices on how to write Python code.
InterSystems ObjectScript is a scripting language to operate with data using any data model of InterSystems Data Platform (Objects, Relational, Key-Value, Document, Globals) and to develop business logic for serverside applications on InterSystems Data Platform.

This will be a short article about PEP 8, the Python style guide.
In a nutshell, PEP 8 provides guidelines and best practices on how to write Python code.
I am trying to create users who only have `%SQL` Role for the INSTANCE. But I am unable to find any documentation on the `
See:
// Instantiate the Security.Users object Set userObj = ##class(Security.Users).%New() // Set the username and password Set userObj.Name = userName Set userObj.FullName = userFullName Set userObj.Namespace = "USER" Set userObj.Roles = "%SQL" Set sc = userObj.ChangePassword(passwd) // Save the user to the database Set ss = userObj.
in order to do analysis on huge data volumes, it is better to take you data to a separate machine for analysis away from the operational machine, so trying to write huge globals or tables into files as is would take a huge space, what could be a solution or best practice ?..in python for instance, there is the pickling option (serializes data to byte string and saves it to a file) to save space, what could be best in object script ?

This will be an introduction to Python programming in the context of IRIS.
Before anything I will cover an important topic: How python works, this will help you understand some issues and limitations you may encounter when working with Python in IRIS.
All the articles and examples can be found in this git repository: iris-python-article
Python is an interpreted language, which means that the code is executed line by line at runtime even when you import a script.
What does this mean ? Let's take a look at the following code:
# introduction.Dear community, I have a confession to make. I have not gotten over Zen yet. Alas, all good things must come to an EOF, so I am currently learning about Angular. I am working on proving to myself that with the right back end and Angular components, I can deliver to myself and my team a very Zen-like experience in this environment. Since this is my first attempt, here is a fair warning: I will be providing some rather large code samples before discussing them. Please warm up your mouse and hand for extensive upcoming scrolling!
Hi Developers!
There is a free ObjectScriptQuality tool for ObjectScript developers who upload solutions on GitHub. This tool helps developers validate ObjectScript code using a variety of rules, based on common code errors.
There are currently 16 rules in this tool, but there are definitely many more rules to consider when testing ObjectScript code.
Could you suggest any other rules to add to this tool?
Note: You can submit it as an idea on the InterSystems Ideas for the 2nd Idea-A-Thon contest
Hello my friends,
I have a problem with Objectscript, why the value of address become like this ?
.png)
everything works fine except the Address,
this is my code, do I need something to make this into real address ? should I put something in my code ?
set paper=obj.PAADMPAPMIDR.PAPMIPAPERDR
if '$isobject(paper) continue
set Address=paper.PAPERStName
thank you for your help
Best Regards,
Steven Henry
Hello my friends,
I have a bit problem with date format, I need to display like this DD-MM-YYYY
I've put the objectscript like this : set DOB=$zd(paper.PAPERDob,15)
and the result is
.png)
Why It cannot show the full year, I mean why 99 or 95 why not 1999 or 1995 ?
Thank You
Best Regards,
Steven Henry
Do not let the title of this article confuse you; we are not planning to take the InterSystems staff out to a fine Italian restaurant. Instead, this article will cover the principles of working with date and time data types in IRIS. When we use these data types, we should be aware of three different conversion issues:
I have built a REST operation to submit a JSON Request Body, and in the JSON Response Object, I need to pull out certain values like pureID, portalURL, and under the identifiers array the ClassifiedID that has a term."en_US" = "Scopus Author ID"
{
"count": 1,
"pageInformation": {
"offset": 0,
"size": 10
},
"items": [
{
"pureId": 0000000000000,
"uuid": "xxxxxxxxxxxxxxxxxxxxx",
"createdBy": "root",
"createdDate": "2024-11-18T22:01:07.I am writing this post primarily to gather an informal consensus on how developers are using Python in conjunction with IRIS, so please respond to the poll at the end of this article! In the body of the article, I'll give some background on each choice provided, as well as the advantages for each, but feel free to skim over it and just respond to the poll.
As most of you are probably aware, Python is currently the most popular programming language among developers around the world - and for good reason.
Hi fellow developers!
Curious if you guys use CreatedAt and LastUpdated properties in your classes?
Created to stamp when the record was created and LastUpdated when it was last updated. Where it can be useful - almost everywhere )) I find it convenient in records sorting (e.g. by creation or last update), in sync (with other systems), and so on, for better analytics.
Do you use it all the time for all the classes?
If don't, why not? What do you use instead?
What property type do you use - %TimeStamp? %DateTime?
What is the best practice to have CreatedAt filled automatically during creation and LastUpdated on every successful save (guess it could be in %OnSave)?
Please share your experience /thoughts?
The below code is not working. its unable retrieve Record count and merge files
Class Util
{
ClassMethod zPyRecordCount(inputfile) As %Integer [ Language = python ]
{
import pandas as pd
import iris
import io
try:
df = pd.read_csv(inputfile, sep='|')
recordcount=len(df.index)
sys.stdout.write(len(df.index))
return recordcount
except Exception as e:
return 0
}
ClassMethod zPymergefiles(file1, file2, outputfilename) As %Boolean [ Language = python ]
{
import pandas as pd
import iris
import io
try:
dataframe1=pd.
Hi noble devs!
Just building a simple frontend->JSON->IRIS backend story, and figured that IRIS while importing via %JSON.Adaptor wants JSON fields to match property names, meaning even should match the case. Like:
{ name: "John",
surname: "Doe"}will have issues while saving the dynamic object to a class Sample.Person with:
Class Sample.Person Extends (%Persistent, %JSON.Adaptor)
{
Property Name: %Sting;
Property Surname: %String;
}As soon as the case is not the same...
Hi all,
We're developing a medical appointment app that connects doctors' schedules to an appointment provider.
The provider is returning us the appointment in the following format:
Thu Jul 03 08:20:00 CEST 2025
It means, 03 july 2025 at 08:20:00 Central European Summer Time (UTC+2)
But we need the following format:
2025-07-03 08:20:00+02:00
Is there any option to convert zone time code (CEST) to a UTC+x ?
How to convert zone time code (CEST, CET, ET, EDT, etc..) in its zone time in UTC (UTC+2, UTC+1, UTC-5, etc..) ?
Best regards
This can be achieved by using the CSV() procedure of the %SQL.Util.Procedures class.
Below is an example of usage code. (Assuming that the file test.csv is in c:\temp.)
Hello,
I have a problem generating QR code in Caché now.
After executing the code
set Status=##Class(%SYS.QRCode).GenerateImage(P0,,.DataURI)
(variable P0 contains data for QR code)
an error is displayed now:
"<NOTOPEN>zGenerate+27^%SYS.QRCode.1",,,,,,,,
("$^zGenerate+27^%SYS.QRCode.1 +1","$^zGenerateImage+4^%SYS.QRCode.1 +1"
This error occurs only on two servers, on the others the code works fine.
When calling the method, I do not specify any external file that should be opened.
Thank you for the answers.
Having been inspired with Shared code execution speed question/discussion, I dare to ask another one which is annoying me and my colleagues for several weeks.
We have a routine called Lib that comprises 200 $$-functions of 1500 code lines total. It was noticed that after calling _any_ function of another rather big routine (1900 functions, 32000 lines) the next call of $$someFunction^Lib(x) is getting 10-20% slower than previous call of the same function.
Embedded Python has been around for a while. You probably followed the tutorials and learned about it. However, if you've tried to combine Python and ObjectScript in real development work, you probably ran into situations where you get an error message like this:
USER>Do ##class(MyClass).SomeMethod() ERROR #5002: ObjectScript error: <PYTHON EXCEPTION> *<class 'ZeroDivisionError'>: division by zero
It's a long string for limited information.
Hey everyone,
I'm diving deeper into Caché ObjectScript and would love to open a discussion around the most useful tips, tricks, and best practices you’ve learned or discovered while working with it.
Whether you're an experienced developer or just getting started, ObjectScript has its own set of quirks and powerful features—some well-documented, others hidden gems. I’m looking to compile a helpful set of ideas from the community.
If you're migrating from Oracle to InterSystems IRIS—like many of my customers—you may run into Oracle-specific SQL patterns that need translation.
Take this example:
SELECT (TO_DATE('2023-05-12','YYYY-MM-DD') - LEVEL + 1) AS gap_date
FROM dual
CONNECT BY LEVEL <= (TO_DATE('2023-05-12','YYYY-MM-DD') - TO_DATE('2023-05-02','YYYY-MM-DD') + 1);
In Oracle:
LEVEL is a pseudo-column used in hierarchical queries (CONNECT BY). It starts at 1 and increments by 1.
CONNECT BY LEVEL <= (...)I am having a hard time trying to figure out the following...
Within a DTC, I was able to take the a EnsLib.HL7.Message source and using
set a= $System.Encryption.Base64Encode(source.RawContent)
set encodedMessage=$Get(a)to take the HL7 message encode it and add it to the Data Class as a string to be sent to an Operation to be sent out as a SOAP Request.
However to make it more universal I tried doing this within a copy of EnsLib.HL7.SOAPOperation
Method SendMessage(pMsgOut As EnsLib.HL7.Message, Output pMsgIn As EnsLib.During the realization of some required functionality, I discovered that I need to use Deflate compression, and found, that IRIS does not offer any options, $system.Util.Compress, works one way open (GZIP/COMPRESS) totally different, even for the same algorithms, I see that what I would expect as a result for Deflate somewhere there, but Compress returns something more. Is there any way to get a correct result using just ObjectScript without a need to use external tools? Was it really so difficult to have Deflate implemented in the first place?
I have a Task that I am trying to write the output to a file. How do I check for if the Output File has been included in the Task Schedule, so I can direct my output of my class to that output file?
Thanks
Scott
Hello,
I have a class with a "Unique" index (pxfactidIndex) on a %Numeric property (pxfactid) (partially-edit code snippet below):
Property pxfactid As %Library.Numeric(MAXVAL = 9223372036854775807, MINVAL = -9223372036854775808, SCALE = 0) [ SqlColumnNumber = 7 ];
Index pxfactidIndex On pxfactid [ Unique ];
Storage Default
{
<Data name="FactDefaultData">
<Value name="1">
<Value>pysubjectid</Value>
</Value>
...
<Value name="6">
<Value>pxfactid</Value>
</Value>
...
</Data>
<DataLocation>^CRMBI.FactD</DataLocation>
<DefaultData>FactDefaultData</DefaultData>
<ExtentLocation>Hi Community,
i'm trying to figure out how to pass a string to a routine from Powershell:
####
ROUTINE ImplUtil
Say(pSomething = "hello, i'm the ROUTINE") public{
w !,pSomething,!
}
####
call: irissession healthconnect -U user 'Say^ImplUtil(12345)'.png)
what's the right way to pass in text?
Are there any direct command to find the length of subscript of global variable? Is it possible to code in objectscript to find the maximum length of subscript in a global variable.
I am struggling on how to pull out individual fields from a JSON. In a previous post someone had mentioned that I could...
If ((tHttpResponseIsObject) && ($ZCONVERT(tHttpResponseContentType,"L") [ "application/json"))
{
set responseData = {}.%FromJSON(tHTTPResponse.Data)
set pResponse = ##class(osuwmc.COM.Response.StringResponse).%New()
if responseData.count =1{
set pResponse.COMPortalURL = responseData.items.%Get(0).portalUrl
set pResponse.COMPureID = responseData.items.%Get(0).pureId
set pResponse.COMTitle = responseData.items.%Get(0).titles.%Get(0I am testing vectorsearch, while doing so I am trying to paginate my resultset for a "next page" function to give me the first, second, third 15 entries within a table.
For this I have two embedding classes. One with a HNSW Index (vectornomicembedtextlatest), and one without (vectornomicembedtexttest).
Calling SELECT ID,PRIMKEY FROM SQLUser.vectornomicembedtexttest LIMIT 5 OFFSET 1 works fine with the first entry having the rowID of 486448. (I deleted old entries in the beginning and reused the table)
SELECT ID,PRIMKEY FROM SQLUser.
Hello Community,
When I run the following code with x undefined in terminal, it throws a syntax error and returns control to the program stack. After issuing a GO command, execution continues, and setting the global variable ^zz1.
code 1:
test.mac
if $Data(@x@(a,b,c)) {
set ^zz1=1212
}
write !,1212,!
//
//or
if $Data(@x@(a,b,c)) set ^zz1=1212
write !,1212,! if I assign the result of $D(@x@(a,b,c)) to a local variable like d using set d=$D(@x@(a,b,c)), and then use if d { ... }, the code fails(global is not set) working as expected.
Code 2