![]() |
|
|
|
#1
|
|||
|
|||
|
Is there an equivlent data type as the "struct" in C
Hi
I want to create a "struct" type variable array in Vizard. Each element in the array contains 5 sub-elements with different data type (i.e. string, int, float, etc.). Any suggestion? Thanks Zhi |
|
#2
|
|||
|
|||
|
#3
|
|||
|
|||
|
It sounds like you just want an array of custom class objects. The following code shows how to create a simple class and add instances of it to a list:
Code:
class MyStruct(object):
def __init__(self,my_int,my_float,my_string):
self.my_int = my_int
self.my_float = my_float
self.my_string = my_string
array = []
array.append( MyStruct(0,0.0,'foo') )
array.append( MyStruct(1,1.0,'bar') )
print array[0].my_string
|
|
#4
|
|||
|
|||
|
That's exactly what I want. Thank you.
Zhi |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| data lose | psykoko | Vizard | 3 | 12-16-2010 08:08 PM |
| Use saved text file data as replay sources problem | mizutani_jun | Vizard | 4 | 10-14-2010 04:49 PM |
| Using 5DT plug-in with the data coming through network... | mcicek | Vizard | 1 | 05-18-2009 05:17 PM |
| Flagging the Data | Elittdogg | Vizard | 5 | 04-11-2008 11:40 AM |
| tracking using quaternarion data | jfreeman | Vizard | 2 | 06-01-2005 08:48 AM |