file pointer array

MRAB python at mrabarnett.plus.com
Wed Jun 6 14:51:03 EDT 2012


On 06/06/2012 19:28, Jon Clements wrote:
> On 06/06/12 18:54, Prasad, Ramit wrote:
>>  data= []
>>  for index in range(N, 1): # see Chris Rebert's comment
>>       with open('data%d.txt' % index,'r') as f:
>>           data.append( f.readlines() )
>>
>
> I think "data.extend(f)" would be a better choice.
>
.extend does something different, and "range(N, 1)" is an empty range
if N > 0.



More information about the Python-list mailing list