building lists of dictionaries
Juho Schultz
juho.schultz at pp.inet.fi
Sun Jul 23 12:15:31 EDT 2006
Tim Chase wrote:
> parinfo = [{'value':0., 'fixed':0, 'limited':[0,0],
> 'limits':[0.,0.]}.copy() for i in xrange(0,6)]
>
> However, this will still reference internal lists that have
> been referenced multiple times, such that
>
> >>> parinfo[5]['limited']
> [0, 0]
> >>> parinfo[4]['limited'][0] = 2
> >>> parinfo[5]['limited']
> [2, 0]
>
Interesting. Cut-and-paste to my python prompt and I get
>>> parinfo[5]['limited']
[0, 0]
Tried both Python 2.4.1 and 2.5 beta, Linux, GCC 4.0.2
More information about the Python-list
mailing list