> Agreed that
>
>     line = line[:line.index('%')]
>
> is slightly more readable than
>
>    line = line.split('%', 1)[0]

How about:

line = line.partition('%')[0]

partition() works even if '%' isn't present.

The index() and split() techniques raise exceptions if '%' isn't
present.

Malcolm
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to