I am newbie who can explain this code to me?
BartC
bc at freeuk.com
Tue Sep 20 08:16:56 EDT 2016
On 20/09/2016 13:12, 380162267qq at gmail.com wrote:
>>>> d = {}
>>>> keys = range(256)
>>>> vals = map(chr, keys)
>>>> map(operator.setitem, [d]*len(keys), keys, vals)
>
> It is from python library. What does [d]*len(keys) mean?
> d is the name of dict but put d in [] really confused me.
>
if len(keys) is 5 then [d]*5 is:
[d,d,d,d,d]
[d] is a list, containing one item, a dict if that is what it is.
--
Bartc
More information about the Python-list
mailing list