Re: self question

2006-07-27 Thread Duncan Booth
Mike wrote: I think the answer is that 'def' is an executable statement in python rather than a definition that the compiler interprets at compile time. As a result the compiler can evaluate 'foo()' when it defines 'bar', so it does. The following works as expected: def bar(): print

Re: self question

2006-07-26 Thread Chris Lambacher
On Tue, Jul 25, 2006 at 08:08:32PM +0200, Sch?le Daniel wrote: [EMAIL PROTECTED] schrieb: cnt = 1 def foo(): global cnt cnt += 1 return cnt def bar(x=foo()): print x bar() # 2 bar() # 2 bar() # 2 Looks to me like you want to use the

Re: self question

2006-07-26 Thread Mike
Schüle Daniel wrote: Hi all, given python description below import random class Node: def __init__(self): self.nachbarn = [] class Graph(object): # more code here def randomizeEdges(self, low=1, high=self.n): pass graph =

self question

2006-07-25 Thread Schüle Daniel
Hi all, given python description below import random class Node: def __init__(self): self.nachbarn = [] class Graph(object): # more code here def randomizeEdges(self, low=1, high=self.n): pass graph = Graph(20)

Re: self question

2006-07-25 Thread dan . gass
cnt = 1 def foo(): global cnt cnt += 1 return cnt def bar(x=foo()): print x bar() # 2 bar() # 2 bar() # 2 Looks to me like you want to use the following programming pattern to get dynamic default arguments: cnt = 1 def foo(): global cnt cnt +=

Re: self question

2006-07-25 Thread Schüle Daniel
[EMAIL PROTECTED] schrieb: cnt = 1 def foo(): global cnt cnt += 1 return cnt def bar(x=foo()): print x bar()# 2 bar()# 2 bar()# 2 Looks to me like you want to use the following programming pattern to get dynamic default arguments: cnt

Re: self question

2006-07-25 Thread Schüle Daniel
correction :) class Graph: settings = { NumNodes : 10, MinNodes : 2, MaxNodes : 5 } def randomizeEdges(self, lowhigh = (settings[MinNodes], settings[MaxNodes])): of course this should be Graph.settings[MinNodes], Graph.settings[MaxNodes]) --