I don't know the type of this data structure

python
rhino

#1

I have a list that looks like this

[object(()), object(()), object((5)), object((7,3)), object(())), object((5,1,0))]

I would like to check if there is a value between the parentheses then extract this value and append it to a new list.

Also, I’m wondering if str((value)) is some kind of a data structure in python?


#2

Uhmm. What are you trying to do? You seem to be talking about text more than anything else “check if there is something between parentheses”

Different data types do different things, you’d select the one that suits your needs.

Maybe you’ve got text and you’re looking to extract something out of it (in which case, it’s not a list)
Or perhaps you shouldn’t have such a list in the first place if it doesn’t match what you are doing.


#3

Parens are always in pairs. This is a mismatch.

A single value in parens is not a data structure, but a value of the same type as that inside the parens.

>>> type((1))
<type 'int'>
>>> type((''))
<type 'str'>
>>> type(([]))
<type 'list'>
>>> type(())
<type 'tuple'>
>>> type(({}))
<type 'dict'>
>>> 

#4

I updated the post, sometimes I have two or more values inside the parens


#5

But is it just text? Or where is the list coming from?


#6

I apologize I just realized I mismatched the parens. I’ll update the post one more time


#7

I’m coding for Grasshopper for Rhino, a 3D modeling software, the list is coming from Rhino and it’s representing the points of intersection between lines and a surface. Actual values look like this

[ArrayPoint3d, ArrayPoint3d, ArrayPoint3d, Array[Point3d]((<Rhino.Geometry.Point3d object at 0x000000000000EC1D [-23.8044134556235,8,8.92537370705992]>)), Array[Point3d]((<Rhino.Geometry.Point3d object at 0x000000000000EC1E [-23.8044134556235,8,8.92537370705992]>, <Rhino.Geometry.Point3d object at 0x000000000000EC1F [-31,2.2566892228611,11.3210518241447]>))]


#8

Then presumably those objects have fields or methods that let you get your values out, so use that.

Also note that the parentheses in that aren’t python code. They’re just text representing those objects.


#9

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.