creating a list of class instances from file / stdin (AGAIN)

Stephen sshelly at pcc.net
Sat Aug 28 08:22:51 EDT 1999


First: thanks to Thomas Wouters and Donn Cave for the assist

I currently have
mb_program = os.popen("my_command | awk {'print $1\" \" $8\" \"$7\"
0\"'}", "r")
for line in mb_program.readlines():
        mb_list.append(string.split(line))

I have a class:
class MyClass:
    def __init__(self,field_one,field_two,field_three)
        self.field_one = field_one blah, blah

  What is the syntax to do:
for line in mb_list:
    create an instance of this class and append it to a new list????
Can I combine the mb_list.append statement above to create instances of
the class while reading the input?
The poroblem I am trying to solve essentially involes a table with three
fields, the first two of which can be duplicates.
Like I said in previous emails, I am pretty new to python, but the news
group is really much more helpful to us newbies than the other languages
I have tried..

PEACE





More information about the Python-list mailing list