On Mon, Aug 16, 2010 at 11:59:57AM +0200, Peter Otten wrote:
> 
> with open(filename) as lines:
>     first_line = next(lines, "")
>     if special(first_line):
>         # ...
>     else:
>         lines = itertools.chain([first_line], lines)
>     for line in lines:
>         # ...

Beautiful. And a nice suggestion to read the itertools docs.
egbert
-- 
Egbert Bouwman - Keizersgracht 197 II - 1016 DS  Amsterdam - 020 6257991
========================================================================
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to