Re: Single format descriptor for list

2016-01-21 Thread Paul Appleby
Thanks all for the answers. Oscar Benjamin wrote: print(('{}th\n' * len(a)).format(*a)) print(''.join(map('{}th\n'.format, a))) Those two look closest to what I was hoping for, I guess, but as Chris Angelico said, it probably is clearer to just loop over the range. -- https://mail.

Single format descriptor for list

2016-01-20 Thread Paul Appleby
In BASH, I can have a single format descriptor for a list: $ a='4 5 6 7' $ printf "%sth\n" $a 4th 5th 6th 7th Is this not possible in Python? Using "join" rather than "format" still doesn't quite do the job: >>> a = range(4, 8) >>> print ('th\n'.join(map(str,a))) 4th 5th 6th 7 Is there an eleg

Re: So what's happening here?

2015-06-05 Thread Paul Appleby
On Fri, 05 Jun 2015 14:55:11 +0200, Todd wrote: > Numpy arrays are not lists, they are numpy arrays. They are two > different data types with different behaviors. In lists, slicing is a > copy. In numpy arrays, it is a view (a data structure representing some > part of another data structure).

So what's happening here?

2015-06-05 Thread Paul Appleby
I saw somewhere on the net that you can copy a list with slicing. So what's happening when I try it with a numpy array? >>> a = numpy.array([1,2,3]) >>> b = a[:] >>> a is b False >>> b[1] = 9 >>> a array([1, 9, 3]) -- https://mail.python.org/mailman/listinfo/python-list