looping through two list simultenously
Michael S
msherman77 at yahoo.com
Sun Oct 29 15:40:58 EST 2006
What if you do it in 2 separate threads?
--- CSUIDL PROGRAMMEr <syedamjad_a at yahoo.com> wrote:
> folks
> I have two lists
>
> i am trying to loop thorough them simultenously.
>
> Here is the code i am using
>
> f1 = os.popen('ls chatlog*.out')
> data1=f1.readlines()
> f1.close()
>
> data1=[x.strip() for x in data1]
> f1 = os.popen('ls chatlog*.txt')
> data=f1.readlines()
> f1.close()
> for eachline in data1 and line in data:
>
> filename='/root/Desktop/project/'+ eachline
> print filename
> outfile=open(filename,'r')
> filename1='/root/Desktop/project/' + line
> print filename1
>
> I get the error that line is not defined.
> Traceback (most recent call last):
> File "list.py", line 16, in ?
> for eachline in data1 and line in data:
> NameError: name 'line' is not defined
>
> Is there any efficient doing this
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list