Read EAN13 barcodes by wilkes

T='\r\x19\x13=#1/;7\x0b'
F='(356;AD=>B'
w=""
R=reduce
while 1:
 q=raw_input()
 if q==w:continue
 w=q
 q=q[5:][:-3]
 q=q[:42]+q[47:]
 q=[q[c*7:7*c+7] for c in range(12)]
 D={}
 G=[]
 for i in range(10):
  o="{:07b}".format(ord(T[i]))
  l=o.replace("0"," ").replace("1","#")
  r=o.replace("0","#").replace("1"," ")
  g="".join(r[::-1])
  D[r]=D[g]=D[l]=i
  G+=[g]
 f=int("".join(map(str,map(int,[x in G for x in q[:6]]))),2)
 d=[F.index(chr(f+40))]
 try:d+=[D[b] for b in q]
 except:continue
 cs=(10-((sum(d[:-1:2])+sum(d[1::2])*3)%10))%10
 d=map(str,d)
 if d[-1]==`cs`:
  print d[0],"".join(d[1:7]),"".join(d[7:])
 else:
  print"ERROR"

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return top