| 1 | initial version |
Your condition can be terser : ...if max(flatten(j))<=12 should do the job.
But your main problem is that you have to read the whole b2 in memory before even starting to process it. Can you somehow (sed comes in mind...) restructure your input file in order to have exactly one element of b2 on each line ? If so, your program could simply do something along the lines of :
fp=open('Your/file/name.txt')
L=[]
l=fp.readline()
while l :
j=eval(l)
if max(flatten(j))<=12: L.append(j)
l=fp.readline()
fp.close()
HTH,
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.