combining the path and fileinput modules SOLVED

Gabriel Genellina gagsl-py at
Tue Nov 28 03:57:48 CET 2006

At Sunday 26/11/2006 01:29, wo_shi_big_stomach wrote:

>for line in fileinput.input(g, inplace=1, backup='.bak'):
># just print 2nd and subsequent lines
>         if not fileinput.isfirstline():
>                 print line.rstrip('\n')
>         # check first line only
>         elif fileinput.isfirstline():
>                 if not'^From ',line):
>                         print line.rstrip('\n')

Just a note: the elif is redundant, use a simple else clause.

Gabriel Genellina
Softlab SRL 

Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! -

More information about the Python-list mailing list