Python syntax in Lisp and Scheme

Jock Cooper jockc at mail.com
Wed Oct 15 13:09:04 EDT 2003


David Eppstein <eppstein at ics.uci.edu> writes:

> In article <eppstein-434779.17173814102003 at news.service.uci.edu>,
>  David Eppstein <eppstein at ics.uci.edu> wrote:
> 
> > > Isn't it true though that the lambda can only contain a single expression
> > > and no statements?  That seems to limit closures somewhat.
> > 
> > It limits lambdas.  It doesn't limit named functions.  Unlike lisp, a 
> > Python function definition can be nested within a function call, and the 
> > inner function can access variables in the outer function's closure.
> 
> To clarify, by "unlike lisp" I meant only that defun doesn't nest (at 
> least in the lisps I've programmed) -- of course you could use flet, or 
> bind a variable to a lambda, or whatever.
> 

Ok so in Python a function can DEF another function in its body.  I assume
this can be returned to the caller.  When you have a nested DEF like that,
is the nested function's name globally visible? 




More information about the Python-list mailing list