Lambda?!
Bo M. Maryniuck
b.maryniuk at forbis.lt
Tue Aug 20 10:12:43 EDT 2002
Python 2.0 (#1, Jan 19 2001, 17:54:27)
[GCC 2.95.2 19991024 (release)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> def foo(a):
... return "<%s>" % a
...
>>> map(lambda bar: foo(bar).upper(), ['test', 'other test'])
['<TEST>', '<OTHER TEST>']
Hura-a!
Python 2.0 (#1, Jan 19 2001, 17:54:27)
[GCC 2.95.2 19991024 (release)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> class foo:
... def bar(self, a):
... return "<%s>" % a
... def spam(self):
... return map(lambda rope: self.bar(rope).upper(), ['test', 'other test'])
...
>>> f = foo()
>>> f.spam()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<stdin>", line 5, in spam
File "<stdin>", line 5, in <lambda>
NameError: There is no variable named 'self'
Huh?!
--
Regards, Bogdan
You have moved the mouse. NT must be restarted for the changes to take effect.
More information about the Python-list
mailing list