Skip to main content

%SYS.Python

class %SYS.Python extends %Library.SystemBase

Provides utilities for loading and using Python modules, running Python commands, and starting the Python shell. For information on working with Python within IRIS, see Using Embedded Python.

Method Inventory

Methods

classmethod Builtins(flags As %Integer) as %CPP.LongLong
Loads the Python builtins module and returns a handle to that module. On failure, this method returns 0. Using this method is equivalent to using Import() to load the Python builtins module.
classmethod Bytes(cmd As %String) as %CPP.LongLong [ Language = cpp ]
Given an ObjectScript string, returns a Python object of type bytes. The input string cannot contain any wide character.
classmethod False() as %CPP.LongLong [ Language = cpp ]
Returns the Python False value.
classmethod Import(name As %String) as %CPP.LongLong [ Language = cpp ]
Loads a Python module and returns a handle to that module. On failure, this method returns 0. Typically you use this method to bind the module to a variable, which you then use to call code within the module. For example:
   set mypython = ##class(%SYS.Python).Import("package.subpackage.name")
   write mypython.helloWorld()
  
classmethod None() as %CPP.LongLong [ Language = cpp ]
Returns the Python None value.
classmethod Run(cmd As %String) as %Integer [ Language = cpp ]
Runs one or more Python commands; to run multiple commands, separate the commands with a new line, $char(10). This method returns 0 on success or -1 on failure.
classmethod Shell(vars As %Integer = 0) as %Status
Starts the interactive Python shell. To use this method, you must have USE permission on the %Developer resource. To exit the shell, type the command quit()
classmethod ToList(contentList As %CPP.BinList) as %CPP.LongLong [ Language = cpp ]
Given an ObjectScript $LIST, this method returns a Python list that contains the same data.
classmethod True() as %CPP.LongLong [ Language = cpp ]
Returns the Python True value.

Inherited Members

Inherited Methods

FeedbackOpens in a new tab