TransWikia.com

Passing python data types as function arguments

Mathematica Asked on November 27, 2020

I’ve a few python data types

edges = [(1,2), (1,3), (1,4), (2,5), (2,6), (5,6), (3,4), (3,7), (6,7), (7,8), (2,9)];
vl = [1,2,3,4,5,6,7,8,9]
ew = {(1, 2) : 49.6, (1,3): 74.4, (1, 4) : 49.6, (2,5): 37.2, (2, 6) : 74.4, (5, 6): 49.6, (3, 4) : 37.2, (3, 7):24.8, (6, 7) : 62, (7, 8) : 37.2, (2, 9) : 24.8}
vd = {1:[75., 25., 0], 2:[115., 45., 0], 3:[10., 5., 0], 4:[45., 0, 0], 5:[90., 60., 0], 6:[45., 55., 0], 7:[0, 25., 0], 8:[10., 50.,0], 9:[115.,  25.,0]};

I want to pass these variables to a function that will convert these to Mathematica expression. I want to do something like below,

solutiond[edges_, vd_, vl_, ew_] := (
  {edges, vl, ew, vd} = 
    ImportString[#, "PythonExpression"]& /@ {"edges","vl","ew","vd"};)

solutiond[edges, vd, vl, ew]

But I am not sure how to pass these input arguments here

{"edges", "vl", "ew", "vd"}

In python I use .format.

Suggestions will be helpful.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP