M
Mike Silva
Hi all,
I'm a Python newbie trying to write a simple program to do some
processing of a text file. So far I'm able to extract all the data I
need from the file into a list (fileinput is very nice!). Here's my
problem. I want the list ("namelist") to contain records, with each
record consisting of a string ("name"), an integer ("flags"), and two
variable-length lists of integers ("list1" and "list2"). I gather
that the corresponding data object in Python would be a sequence of
those four items, correct? So what I want is a list of sequences?
If that is correct, what I don't understand is how to reference and
modify elements of an individual object. For example, I want to do
things like (in pseudocode):
namelist.append( new_record )
.....
namelist[ index ].flags = 99
namelist[ index ].list1.append( 100 )
But I don't see how to reference the individual elements of a data
object. Any tips greatly appreciated!
Mike
I'm a Python newbie trying to write a simple program to do some
processing of a text file. So far I'm able to extract all the data I
need from the file into a list (fileinput is very nice!). Here's my
problem. I want the list ("namelist") to contain records, with each
record consisting of a string ("name"), an integer ("flags"), and two
variable-length lists of integers ("list1" and "list2"). I gather
that the corresponding data object in Python would be a sequence of
those four items, correct? So what I want is a list of sequences?
If that is correct, what I don't understand is how to reference and
modify elements of an individual object. For example, I want to do
things like (in pseudocode):
namelist.append( new_record )
.....
namelist[ index ].flags = 99
namelist[ index ].list1.append( 100 )
But I don't see how to reference the individual elements of a data
object. Any tips greatly appreciated!
Mike