[Tutor] default argument frustration

Alan Gauld alan.gauld at freenet.co.uk
Sat Feb 12 09:41:22 CET 2005


> > 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 in.  Look at a languale like
Common
> Lisp.

Sorry, you are quite right. I meant its the only sane way to do it
given the way Python works.

Lisp and others implement closures and defered evaluation quite
nicely, but I don't think it would be easy to build that into Python.
Although it might be easier now with nested functions etc...

Alan G.



More information about the Tutor mailing list