Julia Quick Syntax Reference by Antonello Lobianco

Julia Quick Syntax Reference by Antonello Lobianco

Author:Antonello Lobianco
Language: eng
Format: epub
ISBN: 9781484251904
Publisher: Apress


7.3.1 Embed Python Code in a Julia Program

Embedding Python code in a Julia program is similar to what we saw with C++, except that you don’t need (for the most part) to worry about transforming data. You define and call the Python functions with py"..." and, in the function call, you can use your Julia data directly:using PyCall JULIA

py"""

def sumMyArgs (i, j):

return i+j

def getNElement (n):

a = [0,1,2,3,4,5,6,7,8,9]

return a[n]

"""

a = py"sumMyArgs"(3,4) # 7

b = py"sumMyArgs"([3,4],[5,6]) # [8,10]

typeof(b) # Array{Int64,1}

c = py"sumMyArgs"([3,4],5) # [8,9]

d = py"getNElement"(1) # 1



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.