Re: calling upper() on a string, not working?

2006-05-17 Thread Bruno Desthuilliers
John Salerno a écrit : Bruno Desthuilliers wrote: def encrypt_quote(original): # Since it's here that we define that the new letters # will be uppercase only, it's our responsability # to handle any related conditions and problems # The other functions shouldn't

calling upper() on a string, not working?

2006-05-16 Thread John Salerno
Can someone tell me what's happening here. This is my code: PUNCT_SPACE_SET = set(string.punctuation + string.whitespace) def filter_letters(original): return ''.join(set(original) - PUNCT_SPACE_SET) 'original' is a string. The above works as expected, but when I change it to return

Re: calling upper() on a string, not working?

2006-05-16 Thread Felipe Almeida Lessa
Em Ter, 2006-05-16 às 20:25 +, John Salerno escreveu: it doesn't seem to work. The full code is below if it helps to understand. Why doesn't it work? What does it do, what did you expect it to do? ''.join(set('hi')) 'ih' ''.join(set('HI')) 'IH' ''.join(set('hiHI')) 'ihIH'

Re: calling upper() on a string, not working?

2006-05-16 Thread John Salerno
Felipe Almeida Lessa wrote: Em Ter, 2006-05-16 às 20:25 +, John Salerno escreveu: it doesn't seem to work. The full code is below if it helps to understand. Why doesn't it work? What does it do, what did you expect it to do? If you run the whole script with the first line (the one not

Re: calling upper() on a string, not working?

2006-05-16 Thread Michal Kwiatkowski
John Salerno wrote: def encrypt_quote(original): original_letters = filter_letters(original) You call filter_letters() which makes upper() on all letters, so original_letters contain only uppercase letters. new_letters = list(string.ascii_uppercase) while True:

Re: calling upper() on a string, not working?

2006-05-16 Thread John Salerno
Michal Kwiatkowski wrote: And here you're translating 'original' (which contains a lot of lowercase letters) with use of trans_table that maps only uppercase characters. This return should be: return original.upper().translate(trans_table) Thank you!!! :) --

Re: calling upper() on a string, not working?

2006-05-16 Thread Larry Bates
John Salerno wrote: Can someone tell me what's happening here. This is my code: PUNCT_SPACE_SET = set(string.punctuation + string.whitespace) def filter_letters(original): return ''.join(set(original) - PUNCT_SPACE_SET) 'original' is a string. The above works as expected,

Re: calling upper() on a string, not working?

2006-05-16 Thread Bruno Desthuilliers
John Salerno a écrit : Can someone tell me what's happening here. This is my code: PUNCT_SPACE_SET = set(string.punctuation + string.whitespace) def filter_letters(original): return ''.join(set(original) - PUNCT_SPACE_SET) 'original' is a string. The above works as expected, but

Re: calling upper() on a string, not working?

2006-05-16 Thread John Salerno
Bruno Desthuilliers wrote: def encrypt_quote(original): # Since it's here that we define that the new letters # will be uppercase only, it's our responsability # to handle any related conditions and problems # The other functions shouldn't have to even know this.

Re: calling upper() on a string, not working?

2006-05-16 Thread Scott David Daniels
John Salerno wrote: Some code, with a request to get case working. Others have shown you where the bug was. You might want to change encrypt_quote like this: XXX def encrypt_quote(original): def encrypt_quote(original, casemap=True): XXX original_letters = filter_letters(original) if

Re: calling upper() on a string, not working?

2006-05-16 Thread Paul Rubin
John Salerno [EMAIL PROTECTED] writes: Now, I know the actual upper() function works, but I can't understand if there's a problem with *when* it's being called, or what's being done with it to get the second result above. You are translating original which still has lower case letters: