[IronPython] self not known in lambda function
Martin Maly
Martin.Maly at microsoft.com
Wed Sep 7 05:01:08 CEST 2005
Thanks for he repro and bug report, Jacques, the bug you see is caused
by missing implementation of closures in IronPython. The closure
implementation is on our to-do list.
Thanks!
Martin
________________________________
From: users-ironpython.com-bounces at lists.ironpython.com
[mailto:users-ironpython.com-bounces at lists.ironpython.com] On Behalf Of
J. de Hooge
Sent: Friday, September 02, 2005 7:18 AM
To: users-ironpython.com at lists.ironpython.com
Subject: [IronPython] self not known in lambda function
# Hi,
#
# Might this be a small bug in IronPython? 'self' is not known inside
the definition of a lambda function
# I tried to insulate the problem in a small (admittedly pointless)
program, not to bother you with bulky app. code
# I am using IronPython 0.9.1
#
<# Kind regards
# Jacques de Hooge info at geatec.com
#
# This example will print the following:
# ======================================
#
# workaround
# Traceback (most recent call last):
# at __main__.Initialize() in
C:\activ_dell\prog\fun\src\funDebug.py:line 29
# at __main__.lamda$1$f5()
# NameError: name 'self' not defined
#
# ======================================
class WorkAround:
def __init__ (self):
global this
this = self
self.setPrintWithoutParams (lambda: this.printWithParams
('workaround'))
def printWithParams (self, text):
print text
def setPrintWithoutParams (self, printWithoutParams):
self.printWithoutParams = printWithoutParams
workAround = WorkAround ()
workAround.printWithoutParams ()
class Problem:
def __init__ (self):
self.setPrintWithoutParams (lambda: self.printWithParams
('problem'))
def printWithParams (self, text):
print text
def setPrintWithoutParams (self, printWithoutParams):</>
self.printWithoutParams = printWithoutParams
problem = Problem ()
problem.printWithoutParams ()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20050906/0796b83a/attachment.html>
More information about the Ironpython-users
mailing list