[Tutor] summer_v04.py

John Fouhy john at fouhy.net
Wed Feb 21 03:55:18 CET 2007


On 21/02/07, Christopher Spears <cspears2002 at yahoo.com> wrote:
> io at io-station-1 ./text_proc 151> ./summer_v04.py
> table.txt
>   File "./summer_v04.py", line 6
>     numCols = max(len(cols) for cols in line_list)
>                               ^
> SyntaxError: invalid syntax

What version of python are you running?

If you are running 2.3.x or earlier, you will need to rewrite this as:

    numCols = max([len(cols) for cols in line_list])

(because you are using a generator expression, and they were only
introduced in 2.4)

-- 
John.


More information about the Tutor mailing list