Lists: Converting Double to Single

Scott David Daniels scott.daniels at acm.org
Tue Feb 27 00:15:19 EST 2007


Leif K-Brooks wrote:
> rshepard at nospam.appl-ecosys.com wrote:
>> ...
>> Unfortunately, when I try to use that last list in a NumPy function,
>> I'm told that it cannot be broadcast to the correct shape. So, what I
>> want to do is strip the extra brackes from each end to leave just
>> [3.5, 4.5, 5.5, 6.5, 7.5].
> 
> l = l[0]

Or, if you want to simultaneously assert there is only one list,
use unpacking like:
     [l] = l

Although I'd prefer to use a better name than l; something like:
     lst = [[3.5, 4.5, 5.5, 6.5, 7.5]]
     [inner] = lst
     print inner, lst

-- 
--Scott David Daniels
scott.daniels at acm.org



More information about the Python-list mailing list