On 2006-02-08, News <[EMAIL PROTECTED]> wrote:
> I am new in using Python
>
> Anyone know how to implement breadth first search using Python? Can Python
> create list dynamically, I want to implement a program which will read data
> from a file and store each line into a list, is this possible?
>
> Thanks for your reply and the structure of the file structure going to be
> read is
>
>
>
> ...
>
>
> The aims is to find out the shortest path(s) for the leaf node(s)
>
> Example:
> 9
> 0 1 1
> 0 4 2
> 1 2 3
> 1 3 4
> 4 3 2
> 4 5 1
> 4 8 2
> 5 6 2
> 5 7 2
> -1
>
> Output:
> Possible solut
Chris McDonough wrote:
> I didn't mean to offend your sensibilities.
Me neither :-)
Peter
--
http://mail.python.org/mailman/listinfo/python-list
Peter Otten wrote:
> Chris McDonough wrote:
>
>>> Can Python
>>> create list dynamically, I want to implement a program which will read
>>> data from a file and store each line into a list, is this possible?
>> L = []
>> [L.append(line) for line in (open('filename.txt')]
>
> Why would you create
Chris McDonough wrote:
> News wrote:
>... Can Python
>> create list dynamically, I want to implement a program which will read
>> data
>> from a file and store each line into a list, is this possible?
>
> L = []
> [L.append(line) for line in (open('filename.txt')]
>
> - C
Woops, crossed wires
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 lin
Chris McDonough wrote:
>> Can Python
>> create list dynamically, I want to implement a program which will read
>> data from a file and store each line into a list, is this possible?
>
> L = []
> [L.append(line) for line in (open('filename.txt')]
Why would you create two lists, one filled only wi
> Anyone know how to implement breadth first search using Python?
Yes. Granted, for more details, you'd have to describe the data
structure you're trying to navigate breadth-first.
> Can Python create list dynamically
Is Perl write-only?
Does Lisp use too many parens?
Of course! :)
Not only
News wrote:
> I am new in using Python
>
> Anyone know how to implement breadth first search using Python?
Breadth-first search of what? It depends what kind of tree you're
searching, but here's a page with a few implementations:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/231503