parameter undefined in procedure

David Smith drs at labs.agilent.com
Fri Feb 25 15:10:21 EST 2000


I have a module named test.py, which contains only the following
definition:

def bar(dictionary):
    list = ['alpha', 'bravo', 'charlie', 'delta', 'echo', 'foxtrot']
    return map( lambda(x): dictionary.get(x,"default"), list)

I import it and run it, and get an error message as follows:

>>> from test import *
>>> bar( {} )
Traceback (innermost last):
  File "<pyshell#65>", line 1, in ?
    bar( {} )
  File "E:\tmp\test.py", line 3, in bar
    return map( lambda(x): dictionary.get(x,"default"), list)
  File "E:\tmp\test.py", line 3, in <lambda>
    return map( lambda(x): dictionary.get(x,"default"), list)
NameError: dictionary
>>> 

Isn't this supposed to work?  The map statement (minus the return) works
as a standalone line if I give it a global variable for dictionary.

	David Smith

P.S. Python announces itself as
Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
IDLE 0.5 -- press F1 for help
>>>



More information about the Python-list mailing list