Jump to content
Debdatta Sen

Python Bridge - 2D Lists from Python cannot be read back into OML

Recommended Posts

In the attached script, one can see that 1D lists such as list1=[1,2,3] can be imported in OML without a hassle.
Whereas when I try to import a list2=[(1,1),(2,2),(3,3)], I receive an error message in OML saying that list2 does not exist.

I use the command getpythonvar().

Am I missing something?

 

I have attached a file that can be used to reproduce my error message.
I am using Compose 2019.3

 

Thanks a bunch,

Deb

error_2DLists_not_readable.oml

Share this post


Link to post
Share on other sites

Hello Debdatta Sen,

 

I think the issue is in what is contained in the list: tuples.

 

Tuples are not supported. You can look at the supported Python DataTypes in the help page.

Here a screenshot:

Capture.JPG

 

Regards,

 

Lorenzo

Share this post


Link to post
Share on other sites

What you can do is to convert your tuple into list. An example:

t = ('my', 'name', 'is', 'mr', 'tuple')

l = list(t)

And then use getpythonvar to retrieve the variable.

 

Regards,

 

Roberta

Share this post


Link to post
Share on other sites
4 minutes ago, L Moretti said:

Hello Debdatta Sen,

 

I think the issue is in what is contained in the list: tuples.

 

Tuples are not supported. You can look at the supported Python DataTypes in the help page.

Here a screenshot:

 

 

Regards,

 

Lorenzo

 

 

Thanks for the quick response!!

Are there any plans to support them in the future?
 

Share this post


Link to post
Share on other sites
7 minutes ago, robertavarela said:

What you can do is to convert your tuple into list. An example:

t = ('my', 'name', 'is', 'mr', 'tuple')

l = list(t)

And then use getpythonvar to retrieve the variable.

 

Regards,

 

Roberta

 

Thanks, for the tip!
But I think it works for 1D lists again isn't it?
I have a tuple again as soon as I have a single 2D element as in t = [('my', 'name'), 'is', 'mr', 'tuple']

Share this post


Link to post
Share on other sites

In this case, you'd need to use list function again in those tuples inside the list:

l[0] = list(l[0])

Which would generate this variable:
[['my', 'name'], 'is', 'mr', 'tuple']

With getpythonvar, the output would be a cell within a cell:

image.png.9dee7c15dddbc0dd883b1c4ba65219b2.png

Regards,

Roberta

Debdatta Sen likes this

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...