merits of Lisp vs Python

Paul Rubin http
Sun Dec 10 04:33:20 EST 2006


"Kay Schluehr" <kay.schluehr at gmx.net> writes:
> > A few months ago, I missed the Condition System most
> > when using Python, and also lexical scope. However, it is nice to work
> > with friends, who know Python and not Lisp.)
> 
> Could you explain in which way Python lacks lexical scoping?

Python has lexical scope but you can't update lexical variables from
scopes other than the innermost or outermost (global) scope.  I.e:

   def counter():
     x = 0
     def g():
       x += 1
       return x
     return g

   c = counter()
   print c()

doesn't do what you'd hope.  Yes there are workarounds but they're not
all that satisfactory.



More information about the Python-list mailing list