On Thu, 26 Apr 2007 22:12:54 -0400, I wrote > On Thu, 26 Apr 2007 18:39:23 -0300, Gerardo Herzig wrote > > Hi. Im looking for an I25 barcode generator.[...] > > [...]it shouldn't be too hard to make one. >
And it wasn't: def i25(x): """i25(x) -> string Encode string of digits into I25 barcode. The input string must consist of an even number of digits. The output string represents the I25 barcode of the input string with N = narrow bar, W = wide bar, n = narrow space, w = wide space. """ alphabet = ( "NNWWN", "WNNNW", "NWNNW", "WWNNN", "NNWNW", "WNWNN", "NWWNN", "NNNWW", "WNNWN", "NWNWN" ) if not x.isdigit(): raise ValueError, "Input string must consist of digits." if len(x)%2!=0: raise ValueError, "Input string must be of even length." bars = "".join(alphabet[int(c)] for c in x[0::2]) spaces = "".join(alphabet[int(c)] for c in x[1::2]).lower() interleaved = "".join(t[0]+t[1] for t in zip(bars,spaces)) return "NnNn"+interleaved+"WnN" Rendering the resulting string into the desired graphical format is left as an exercise for the reader. HTH, Carsten. -- http://mail.python.org/mailman/listinfo/python-list