[Tutor] Thoughts on little lambda

Doug.Shawhan@gecits.ge.com Doug.Shawhan@gecits.ge.com
Mon, 11 Mar 2002 11:48:41 -0500


>>> from __future__ import nested_scopes
>>> def addn(n):
	return lambda x:x+n
SyntaxError: local name 'n' in 'addn' shadows use of 'n' as global in nested
scope 'lambda' (<pyshell#3>, line 1)
>>> 

Fiddlesticks. Off to d/l 2.2 :-)

d

-----Original Message-----
From: Scott Widney [mailto:SWidney@ci.las-vegas.nv.us]
Sent: Friday, March 08, 2002 4:24 PM
To: Shawhan, Doug (CAP, ITS, US)
Cc: tutor@python.org
Subject: RE: [Tutor] Thoughts on little lambda


> Errr...
> 
> I tried this particular excersise and had a problem...
> 
> ------------------------------------------------------
> Python 2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32 bit 
> (Intel)] on win32
> Type "copyright", "credits" or "license" for more information.
> IDLE 0.8 -- press F1 for help
> >>> def addn(n):
> 	return lambda x:x+n
> SyntaxError: local name 'n' in 'addn' shadows use of 'n' as 
> global in nested
> scope 'lambda' (<pyshell#1>, line 1)
> ------------------------------------------------------
> 
> Am I missing something?

from __future__ import nested_scopes


Scott