[Python-Dev] 2.5 and beyond (original) (raw)

Bill Chiles billchi at microsoft.com
Tue Jul 4 01:17:36 CEST 2006


For Common Lispers and probably Schemers, Python has some surprising semantics around scope and lifetime extent of variables. Three that leap out at me are:

Bill

-----Original Message----- From: python-dev-bounces+billchi=microsoft.com at python.org [mailto:python-dev-bounces+billchi=microsoft.com at python.org] On Behalf Of Bill Janssen Sent: Friday, June 30, 2006 6:31 PM To: Giovanni Bajo Cc: Phillip J. Eby; Ka-Ping Yee; Guido van Rossum; Tim Peters; python-dev at python.org Subject: Re: [Python-Dev] 2.5 and beyond

>>> a = [] >>> for i in range(10): ... a.append(lambda: i) ... >>> print [x() for x in a] [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]

Isn't this exactly what you'd expect? Maybe I've been writing Python for too long... :-).

Bill


Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/billchi%40microsoft.co m



More information about the Python-Dev mailing list