breadth first search

mrmakent at cox.net mrmakent at cox.net
Wed Feb 8 12:19:21 EST 2006


Chris McDonough wrote:

> L = []
> [L.append(line) for line in (open('filename.txt')]

Ouch.

Did you perhaps mean:

L = [ line for line in open('filename.txt') ]

Or, with better error handling:

try:
    f = open('filename.txt')
except IOError:
    # handle error here
else:
    L = [ line for line in f ]




More information about the Python-list mailing list