Sorry Jonas,

I don't understand what you are trying to do at all.
The subject line and your code snippets don't seem 
to match up.

> Subject: [Tutor] iterating in the same line

>I would check 3 words at the starting of a line
> 
> s=['foo','bar','qwe']
> 
> if ln.startswith(s):   (this is bad)

Why is it bad -- other than it doesn't work!
I think you mean something like

for st in s:
  if line.startswith(st):  do something

> if max(map(ln.startswith,s)):

But this does something completely different!

This selects the 'biggest' line that starts with anything in s.
then if the biggest line is not null does something?

> reduce(lambda m,n:m or n, map(ln.startswith, s))

And this does something different again.
It uses map to create a list containg ln if ln startswith 
one of the strings in s, then tries to reduce that list 
to one element(which it already is!) by 'or'ing the elements.

I can't even begin to guess from that what it is you are 
actually trying to do.

Can you give us more explanation and maybe some sample data?

Alan G.

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to