list behavior
anton muhin
antonmuhin.REMOVE.ME.FOR.REAL.MAIL at rambler.ru
Mon Oct 27 13:22:19 EST 2003
Rene Aguirre wrote:
> Hello everybody,
>
> I needed to add a list to a dictionary, something very simple:
>
>>>>d = {}
>>>>l = []
>>>>l.append(1)
>>>>d["one"] = l
>>>>d
>
> {'one': [1]}
>
> Buen, when I just move the 'append' statement to the dictionary
> assigment then:
>
>>>>l = []
>>>>d = {}
>>>>d["one"] = l.append(1)
>>>>d
>
> {'one': None}
>
> Not what I expected, then I came to the conclusion that
> [].append(value) returns 'None', why?
>
> Rene A.
append is what is called procedure in other languages.
d["one"].append(1) should work
hth,
anton.
More information about the Python-list
mailing list