Re: [Tutor] Masking operation

2009-10-15 Thread Rich Lovely
2009/10/15 Kent Johnson : > On Wed, Oct 14, 2009 at 10:48 PM, Wayne wrote: > >> 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())) >>

Re: [Tutor] Masking operation

2009-10-15 Thread Kent Johnson
On Wed, Oct 14, 2009 at 10:48 PM, Wayne wrote: > 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 With zip() and a ge

Re: [Tutor] Masking operation

2009-10-14 Thread Wayne
On Wed, Oct 14, 2009 at 6:31 PM, Rich Lovely 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

Re: [Tutor] Masking operation

2009-10-14 Thread Alan Gauld
"Wayne" wrote I've searched "Python masking" and various other terms in Google and the python docs and came up with nothing useful. Try the Using the OS topic in my tutorial. There is a sidebar in there about using the bitwise operators to do masking about half way down. HTH, -- Alan Gau

Re: [Tutor] Masking operation

2009-10-14 Thread Rich Lovely
2009/10/14 Wayne : > I've searched "Python masking" and various other terms in Google and the > python docs and came up with nothing useful. > This is just a bit of a hobby project that was inspired by some assembly > homework that one of my friends is now doing and I did last semester. The > assig

[Tutor] Masking operation

2009-10-14 Thread Wayne
I've searched "Python masking" and various other terms in Google and the python docs and came up with nothing useful. This is just a bit of a hobby project that was inspired by some assembly homework that one of my friends is now doing and I did last semester. The assignment was to create a program