default value in __init__

David C. Ullrich dullrich at sprynet.com
Thu Oct 16 15:45:38 EDT 2008


In article <48f505c8$0$20216$426a74cc at news.free.fr>,
 Bruno Desthuilliers <bdesth.quelquechose at free.quelquepart.fr> wrote:

> David C. Ullrich a écrit :
> > In article <48ef37fe$0$22798$426a34cc at news.free.fr>,
> >  Bruno Desthuilliers <bruno.42.desthuilliers at websiteburo.invalid> 
> >  wrote:
> > 
> >> David C. Ullrich a écrit :
> (snip)
> >>> Seems to me that people often site the "important warning" in
> >>> the tutorial. Of course there's no reason anyone would bother
> >>> going through the tutorial
> >> Indeed. No reason at all.
> >>
> >>> - just for fun I looked in the
> >>> official Python Reference Manual to see whether they're explicit
> >>> about this or require the reader to figure it out from something
> >>> else they say.
> >>>
> >>> There's a section titled "7.6 Function definitions". About halfway
> >>> through that section there's a _bold face_ statement 
> >>> "Default parameter values are evaluated when the function definition is 
> >>> executed.", followed by an explanation of how that can lead to
> >>> the sort of problem above.
> >> But there's no reason to read the reference manual neither.
> >>
> >>> So I guess it _is_ awfully dangerous. They
> 
> Hum... Who are "they", exactly ?
> 
> >>> should really explain
> >>> this aspect of the language's behavior to people who don't read
> >>> the formal definition and also don't work through the tutorial.
> >> You mean : "to people that don't bother reading the FineManual *nor* 
> >> searching the newsgroup / ML archives ?"
> > 
> > Yes. Also add "don't read any books".
> 
> Indeed.
> 
> > I think I started with some
> > book
> 
> As far as I'm concerned, I started with the FineManual(tm)'s tutorial.
> 
> (snip)
> 
> >> Well... How to say.. Is there any chance these people will read anything 
> >> *at all* ?
> > 
> > No. That's exactly the point! 
> 
> Yeps. But I don't think we derive the same conclusions from that point.

Erm, I think maybe your irony detector needs a little calibration...

> > [...]
> 
> > In particular default parameters should work the way the user
> > expects! The fact that different users will expect different
> > things here is no excuse...

I was worried someone might not realize I was being sarcastic,
which is why I threw in this obvious impossibility

> If different users expect different - mostly incompatible - things, how 
> would it be possible to have it working "the way the user expect" ? 

but I guess it wasn't enough.

> Should Python grow some telepathic features to guess the user's 
> expectations and modifies itself to meet these expectations ?-)

-- 
David C. Ullrich



More information about the Python-list mailing list