Need better way to unpack a list

Nx nomail at nomail.com
Wed Aug 17 04:25:14 EDT 2005


Is there a better solution to following problem :

I want to unpack a list into variables
the list is created at runtime and I do not know
how many items there will be , but I know not more than 25.
The list unpacks into variables which are prev. defined as
line1,line2....line25 which are actually the names of lineedit fields in
a Qt gui application and which need to be populated.
I currently use following to achieve that :

c=0
while c < len(mylinelist):
     c = c + 1
     if c==1:
         self.line1.setText(mylinelist[c])
     if c==2 :
         self.line2.setText(mylinelist[c])
     .
     .
     .
     if c==25:
        self.line25.setText(mylinelist[c])

I rather have someting like
pseudo code follows:

  self.line+"c"+.setText(mylinelist[c])

How to do that ?

Nx



More information about the Python-list mailing list