Re: recursion in Class-methods?

2008-06-27 Thread Bruno Desthuilliers
defn noob a écrit : class Graph(object): where does anyone write like that? Almost everywhere nowadays. I've seen only examples like i have written. Most of the doc has still not been updated since the introduction of newstyle classes years ago. You'll find more here:

Re: recursion in Class-methods?

2008-06-26 Thread Bruno Desthuilliers
klant a écrit : do i need to call Graph.find_path? g = Graph({'A': ['B', 'C'], 'B': ['C', 'D'], 'C': ['D'], 'D': ['C'], 'E': ['F'], 'F': ['C']}) g __main__.Graph instance at 0x01D74378 g.find_all_paths('A', 'C')

Re: recursion in Class-methods?

2008-06-26 Thread defn noob
class Graph(object): where does anyone write like that? I've seen only examples like i have written. is the object then passed to init? class Graph(object): def __init__(self, dictionary): self.structure = dictionary or class Graph(object): def __init__(self, object):

Re: recursion in Class-methods?

2008-06-26 Thread defn noob
if start == end: return path if not self.dictionary.has_key(start): if start not in self.dictionnary: return None for node in self.dictionary[start]: if node not in path: newpath =

Re: recursion in Class-methods?

2008-06-26 Thread Saul Spatz
defn noob wrote: if start == end: return path if not self.dictionary.has_key(start): if start not in self.dictionnary: return None for node in self.dictionary[start]: if node not in path: newpath =

recursion in Class-methods?

2008-06-25 Thread klant
do i need to call Graph.find_path? g = Graph({'A': ['B', 'C'], 'B': ['C', 'D'], 'C': ['D'], 'D': ['C'], 'E': ['F'], 'F': ['C']}) g __main__.Graph instance at 0x01D74378 g.find_all_paths('A', 'C') Traceback (most recent call

Re: recursion in Class-methods?

2008-06-25 Thread Roopesh
Wrong: newpath = find_path(self.dictionary, node, end, path) newpaths = find_all_paths(self.dictionary, node, end, path) newpath = find_shortest_path(self.dictionary, node, end, path) Correct; newpath = self.find_path(self.dictionary, node, end, path) newpaths =