represents an external evaluation of "code" with parameters given by assoc.
calls the function func with the given arguments arg1, arg2, ….
sets the attribute "attr" of obj to the given value val.
represents the external operation named "op" using arguments arg1, arg2, ….
Details

- ExternalOperation represents a remote procedure call to be executed in an ExternalEvaluate system, such as "Python", "Ruby", "NodeJS".
- Available operations "op" in ExternalOperation["op",…] vary from system to system.
- ExternalOperation[…] can be evaluated with ExternalEvaluate["system",ExternalOperation[…]].
- ExternalOperation["op",params…][args…] evaluates to ExternalOperation["op",args…,params…].
- ExternalObject[…][ExternalOperation[…]] is equivalent to ExternalEvaluate["system",ExternalOperation[…][ExternalObject[…]]].
Examples
open allclose allBasic Examples (1)Summary of the most common use cases
Create an ExternalOperation to evaluate the code "2+2":

https://wolfram.com/xid/0d6f993mi6-006yhw

Run the operation using ExternalEvaluate:

https://wolfram.com/xid/0d6f993mi6-jggtpy

Scope (7)Survey of the scope of standard use cases
ExternalOperation does not evaluate:

https://wolfram.com/xid/0d6f993mi6-pjl6yf

You can use downvalues to accumulate arguments:

https://wolfram.com/xid/0d6f993mi6-n8bpav

Run the operation using ExternalEvaluate:

https://wolfram.com/xid/0d6f993mi6-2yqi27

Define an operator form for the "GetAttribute" operation:

https://wolfram.com/xid/0d6f993mi6-5anz7l


https://wolfram.com/xid/0d6f993mi6-dtp17r

Create an ExternalObject:

https://wolfram.com/xid/0d6f993mi6-5jnwid

Use the operator over the object to the specified attribute:

https://wolfram.com/xid/0d6f993mi6-i15vm2

The same can be done by creating a new operation:

https://wolfram.com/xid/0d6f993mi6-8a1c60

The operation needs to be evaluated by using ExternalEvaluate:

https://wolfram.com/xid/0d6f993mi6-ya29yj


https://wolfram.com/xid/0d6f993mi6-13b0yv
External Operations (5)
"Eval" (1)
Run an ExternalOperation that represents arbitrary code evaluation in Python:

https://wolfram.com/xid/0d6f993mi6-swuxd6

Use the second argument to pass an evaluation context:

https://wolfram.com/xid/0d6f993mi6-f36uo2

"Call" (1)
Define an ExternalOperation that creates a function in Python:

https://wolfram.com/xid/0d6f993mi6-9h6w6f

Call the function by running the ExternalOperation "Call":

https://wolfram.com/xid/0d6f993mi6-rm5gdc

Run the operation using ExternalEvaluate:

https://wolfram.com/xid/0d6f993mi6-tkrdu6

Any argument of the "Call" operation can be an ExternalOperation:

https://wolfram.com/xid/0d6f993mi6-bvf64x

Arguments can also be passed directly in ExternalEvaluate by doing:

https://wolfram.com/xid/0d6f993mi6-7rmkso

The result is equivalent to running the following Python code:

https://wolfram.com/xid/0d6f993mi6-knfcqv

"GetAttribute" (1)
Start a Python session to work with dates:

https://wolfram.com/xid/0d6f993mi6-d7wsz4
Return an ExternalObject for a datetime object:

https://wolfram.com/xid/0d6f993mi6-zkk45a

Extract the year attribute by using "GetAttribute":

https://wolfram.com/xid/0d6f993mi6-jfln28

The result is equivalent to running the following Python code:

https://wolfram.com/xid/0d6f993mi6-b1282w


https://wolfram.com/xid/0d6f993mi6-u5uste
"SetAttribute" (1)
Start a Python session to work with decimal numbers:

https://wolfram.com/xid/0d6f993mi6-lf5zl4
Get the context for the decimal module:

https://wolfram.com/xid/0d6f993mi6-ds819o


https://wolfram.com/xid/0d6f993mi6-602p3t
Check that the precision was set to 6:

https://wolfram.com/xid/0d6f993mi6-4c6pmi


https://wolfram.com/xid/0d6f993mi6-cbzrou

The result is equivalent to running the following Python code:

https://wolfram.com/xid/0d6f993mi6-by53sd

https://wolfram.com/xid/0d6f993mi6-c3tha6
"Cast" (1)
Create an ExternalObject that represents the current date:

https://wolfram.com/xid/0d6f993mi6-2ful7n

https://wolfram.com/xid/0d6f993mi6-lh03sx

Use "Expression" to return the object as a Wolfram Language expression:

https://wolfram.com/xid/0d6f993mi6-k0ehns

The Cast operation can also run in ExternalObject subvalues:

https://wolfram.com/xid/0d6f993mi6-jeanm1

The symbol Expression is a shortcut for the same:

https://wolfram.com/xid/0d6f993mi6-pdqz05

Return the object as a string:

https://wolfram.com/xid/0d6f993mi6-gqmk1m

The symbol String is a shortcut for the same:

https://wolfram.com/xid/0d6f993mi6-yg8hmp

Return the object as an ExternalObject:

https://wolfram.com/xid/0d6f993mi6-yt1eew

The symbol ExternalObject is a shortcut for the same:

https://wolfram.com/xid/0d6f993mi6-xiafcd

The same can be achieved by using "ReturnType" in ExternalEvaluate:

https://wolfram.com/xid/0d6f993mi6-bnmhjm


https://wolfram.com/xid/0d6f993mi6-wdx7xb
Properties & Relations (5)Properties of the function, and connections to other functions
ExternalOperation can be used to extract the operation from an ExternalObject:

https://wolfram.com/xid/0d6f993mi6-p7tziq

The same can be done with an ExternalFunction:

https://wolfram.com/xid/0d6f993mi6-dif7v0

ExternalOperation can be used as an argument to ExternalFunction:

https://wolfram.com/xid/0d6f993mi6-nznvfo

The same can be done by using ExternalEvaluate:

https://wolfram.com/xid/0d6f993mi6-oqgoa0

ExternalOperation can be used as an argument to ExternalObject:

https://wolfram.com/xid/0d6f993mi6-ixfzu5

The executed operation is identical to this one:

https://wolfram.com/xid/0d6f993mi6-mu3hbe

Which can be executed with ExternalEvaluate:

https://wolfram.com/xid/0d6f993mi6-7b07hd

The result is equivalent to running the following Python code:

https://wolfram.com/xid/0d6f993mi6-pzgu6c

Create an ExternalObject to work with the sys module:

https://wolfram.com/xid/0d6f993mi6-tp546g

When a string is used, the "GetAttribute" operation is executed in most evaluators, including Python:

https://wolfram.com/xid/0d6f993mi6-egqaxa

The result is equivalent to running an explicit "GetAttribute" operation:

https://wolfram.com/xid/0d6f993mi6-9dppjt

Multiple operations can be concatenated using multiple arguments in ExternalObject:

https://wolfram.com/xid/0d6f993mi6-o4lbb2


https://wolfram.com/xid/0d6f993mi6-oxalvx

Which can be written in a more compact way:

https://wolfram.com/xid/0d6f993mi6-ey2dbb

Wolfram Research (2024), ExternalOperation, Wolfram Language function, https://reference.wolfram.com/language/ref/ExternalOperation.html.
Text
Wolfram Research (2024), ExternalOperation, Wolfram Language function, https://reference.wolfram.com/language/ref/ExternalOperation.html.
Wolfram Research (2024), ExternalOperation, Wolfram Language function, https://reference.wolfram.com/language/ref/ExternalOperation.html.
CMS
Wolfram Language. 2024. "ExternalOperation." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ExternalOperation.html.
Wolfram Language. 2024. "ExternalOperation." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ExternalOperation.html.
APA
Wolfram Language. (2024). ExternalOperation. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ExternalOperation.html
Wolfram Language. (2024). ExternalOperation. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ExternalOperation.html
BibTeX
@misc{reference.wolfram_2025_externaloperation, author="Wolfram Research", title="{ExternalOperation}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/ExternalOperation.html}", note=[Accessed: 07-June-2025
]}
BibLaTeX
@online{reference.wolfram_2025_externaloperation, organization={Wolfram Research}, title={ExternalOperation}, year={2024}, url={https://reference.wolfram.com/language/ref/ExternalOperation.html}, note=[Accessed: 07-June-2025
]}