On Wed, Oct 14, 2009 at 6:31 PM, Rich Lovely <roadier...@googlemail.com>wrote:
> > Specifically, cycle and izip. itertools.cycle is the trick here, izip > is a more efficient (in this case) version of zip. Ahah! Cycle is exactly what I wanted - I thought there was something like this but I forgot where I found it. Using zip is redundant for me, this is what my function looks like now: def crypt(msg, mask): m = itertools.cycle(mask) word = '' for l in msg: word += chr(ord(l) ^ ord(m.next())) return word and works quite perfectly. Alan - I wish I had known this a few days ago when I was trying to use masks to set debug levels. Oh well - having experimented with what I've learned in my discrete structures class about and, or, xor, I've learned what I need to know, and reviewing your tutorial really helps put some of the pieces together that I wasn't able to come up with on my own. Thanks all! -Wayne
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor