Preferred method for "Assignment by value"
buzzard at urubu.freeserve.co.uk
Tue Apr 15 21:07:14 CEST 2008
hall.jeff at gmail.com wrote:
> Thank you both, the assigning using slicing works perfectly (as I'm
> sure you knew it would)... It just didn't occur to me because it
> seemed a little nonintuitive... The specific application was
> def dicttolist (inputdict):
> for k, v in inputdict.iteritems():
> temp = v
> return finallist
finallist = [[k] + v for k, v in inputdict.iteritems()]
the list concatenation creating new lists.
More information about the Python-list