Heh, yet another questoinf rom me :)
Joshua Macy
amused at webamused.com
Sat Mar 25 00:30:41 EST 2000
Most likely, you would replace your table with a list, e.g.:
>>> blaat_table = [ [0, "lkjl", 'c'], [5, "lkjj", 'c']]
Then you could manipulate it like so:
>>> blaat_table[0]
[0, 'lkjl', 'c']
>>> blaat_table[0][1]
'lkjl'
>>> for row in blaat_table:
... for column in row:
... print column
...
0
lkjl
c
5
lkjj
c
>>>
The nice thing about lists is that they're mutable, so:
>>> blaat_table.append( [10, "lkkl", 'e'])
>>> blaat_table[2][0]
10
>>> blaat_table[0].append('hi')
>>> blaat_table[0]
[0, 'lkjl', 'c', 'hi']
>>>
You could choose to use tuples if you wanted the blaat_table to be
immutable.
Joshua
Falknor wrote:
>
> Allo again peoples.
>
> I'm comin from a C/C++ background here and am still tryin to get situated.. So excuse any overly goofy things I ask for the next week or so if you please. :)
>
> What would be the best way to do something like this in python...
>
> struct blaat
> {
> int blaat2;
> char* blaat3;
> char blaat4;
> }
>
> struct blaat blaat_table[] =
> {
> { 0, "lklj", 'c'},
> { 5, "jkjj", 'a'}
> }
>
> i know you'd convert the struct over to a class.. IE:
> class blaat:
> blaat2 = 0
> blaat3 = ""
> blaat4 = ""
>
> but I don't quite know what I would do in place of the table... Any help? :)
>
> JD
>
> ______________________________________________________________
> Get free Internet service and email at http://www.worldspy.com
More information about the Python-list
mailing list