counting lines using fileinput module

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Thu Feb 14 03:23:14 CET 2008


En Wed, 13 Feb 2008 23:47:11 -0200, Robert <robert.pena at gmail.com>  
escribió:

> I would like to count lines in a file using the fileinput module and I
> am getting an unusual output.
> ------------------------------------------------------------------------------
> #!/usr/bin/python
> import fileinput
>
> # cycle through files
> for line in fileinput.input():
>    if (fileinput.isfirstline()):
>       if (fileinput.lineno > 1):

You forget the () after lineno

-- 
Gabriel Genellina




More information about the Python-list mailing list