Artigo
· Jul. 24 1min de leitura

Executando Python no Terminal do InterSystems IRIS

Você está curioso para saber como executar scripts Python diretamente no terminal do InterSystems IRIS ou Caché? 🤔
Boa notícia: é fácil! 😆
O IRIS oferece suporte ao Embedded Python, permitindo que você use Python de forma interativa dentro do terminal do IRIS.

Como acessar o Shell do Python?

Para iniciar o shell do Python a partir do terminal do IRIS, basta executar o seguinte comando:

do ##class(%SYS.Python).Shell()

Esse comando abre um shell interativo do Python dentro do terminal do IRIS. A partir daí, você pode escrever e executar código Python como faria em um ambiente Python normal.

Como sair do Shell?

>>> quit()

Isso encerrará o shell do Python e retornará ao prompt do ObjectScript.

 

USER>do ##class(%SYS.Python).Shell()
 
Python 3.9.5 (default, May 31 2022, 12:35:47) [MSC v.1927 64 bit (AMD64)] on win32
Type quit() or Ctrl-D to exit this shell.
>>> name = 'Vachan'
>>> age = 25
>>> print('Name: ',name,'\nAge:',age)
Name:  Vachan
Age: 25
>>> quit()

 

Essa é uma ótima maneira de aproveitar os recursos do Python dentro do ambiente InterSystems.
Seja para experimentar, testar lógicas ou integrar com ObjectScript, o shell embutido do Python torna tudo mais rápido e flexível.

Bom código! 👨‍💻

Discussão (0)1
Entre ou crie uma conta para continuar