Re: [Tutor] default argument frustration

2005-02-13 Thread Alan Gauld
> I've combined a few email's worth of quoting as no previous post had > all the elements I wanted to refer to. > > interface. The function should return the same result each time > > you call it with the same input. The only way to achieve that > > is to have the default calculated once. I f

Re: [Tutor] default argument frustration

2005-02-13 Thread Alan Gauld
> Alan was saying that there is no other obvious way for Python to do it. > > What I am still not clear on it is why Alan's claim is true. (Not > doubting it is, but would like to get why it is.) Doubt away, my knowledge of Python internals is largely intuitive, I've never got round to reading the

Re: [Tutor] default argument frustration

2005-02-12 Thread Brian van den Broek
I've combined a few email's worth of quoting as no previous post had all the elements I wanted to refer to. Alan Gauld said unto the world upon 2005-02-11 13:30: >> >>FOR THE LOVE OF MIKE can someone tell me even one reason why this >>isn't a misfeature?!?! >> > > Its the only sane way to impleme

Re: [Tutor] default argument frustration

2005-02-12 Thread Alan Gauld
> > interface. The function should return the same result each time > > you call it with the same input. The only way to achieve that > > is to have the default calculated once. > > IBTD. > With full lexical scope you only need to calculate the default argument > in the lexical scope it was defined

Re: [Tutor] default argument frustration

2005-02-11 Thread Karl Pflästerer
On 11 Feb 2005, [EMAIL PROTECTED] wrote: >> FOR THE LOVE OF MIKE can someone tell me even one reason why this >> isn't a misfeature?!?! > Its the only sane way to implement default arguments. The whole > point of function definitions is that they provide a single concise > interface. The funct

Re: [Tutor] default argument frustration

2005-02-11 Thread Alan Gauld
> > FOR THE LOVE OF MIKE can someone tell me even one reason why this > isn't a misfeature?!?! > :-) Its the only sane way to implement default arguments. The whole point of function definitions is that they provide a single concise interface. The function should return the same result each

Re: [Tutor] default argument frustration

2005-02-11 Thread Kent Johnson
Brian van den Broek wrote: At first, I ended up with every single node being a copy of the first one processed. A bit of weeping later, I realized that this is from the feature [?] of Python that default arguments are evaluated just once. (Note the comment added above.) FOR THE LOVE OF MIKE ca

[Tutor] default argument frustration

2005-02-11 Thread Brian van den Broek
Alan Gauld said unto the world upon 2005-02-10 02:58: class Node: def __init__(self,lines=[]): # here's the zowie BvdB self.lines = lines def append(self,item): self.lines.append(item) def parse(self): #