[Pythonmac-SIG] Nested lists

Max Haas Max.Haas@unibas.ch
Tue, 29 Feb 2000 08:43:36 +0100


Hi,

ask for help for a newbie question (can't find the starting point for a
solution)

Question:
I need some void lists, e.g.

map(lambda x:[] * 6, range(6))

Works fine.

When I try to implement this in a function I get something like:

def mklist(num):
    return map(lambda x:[] * num, range(num))
    
and mklist(4) yields [[], [], [], [], [], []]

This works in 'Python interactive'. In a normal Python window I get a NameError.
I can't figure out the basic difference between the behaviour of 'Python
interactive' and a 'normal' Python window. 

Any help much appreciated.

Max