string.replace doesn't removes ":"

Walter Hurry walterhurry at lavabit.com
Wed Feb 13 19:16:34 CET 2013


On Wed, 13 Feb 2013 16:55:36 +0000, Mark Lawrence wrote:

> On 13/02/2013 16:34, Rick Johnson wrote:
>> On Wednesday, February 13, 2013 1:10:14 AM UTC-6, jmfauth wrote:
>>>
>>>>>> d = {ord('a'): 'A', ord('b'): '2', ord('c'): 'C'}
>>>>>> 'abcdefgabc'.translate(d)
>>> 'A2CdefgA2C'
>>>>>>
>>>>>>
>>>>>> def jmTranslate(s, table):
>>> ...     table = {ord(k):table[k] for k in table}
>>> ...     return s.translate(table)
>>> ...
>>>>>> d = {'a': 'A', 'b': '2', 'c': 'C'}
>>>>>> jmTranslate('abcdefgabc', d)
>>> 'A2CdefgA2C'
>>>>>> d = {'a': None, 'b': None, 'c': None}
>>>>>> jmTranslate('abcdefgabc', d)
>>> 'defg'
>>>>>> d = {'a': '€€€€€', 'b': '€€€€', 'c': '€€€€'}
>>>>>> jmTranslate('abcdefgabc', d)
>>> '€€€€€€€€€€€€€defg€€€€€€€€€€€€€'
>>
>> [quip] I just really prefer a cryptic solution to a problem when a
>> simplistic and consistent approach would suffice.[/quip] TO HELL WITH
>> THE ZEN!
>>
>> "Beautiful is better than ugly."
>>    BROKEN!
>>
>> "Explicit is better than implicit."
>>    BROKEN!
>>
>> "Simple is better than complex."
>>    BROKEN!
>>
>> "Sparse is better than dense."
>>    BROKEN!
>>
>> "Readability counts."
>>    BROKEN BROKEN BROKEN!!!!
>>
>> "Special cases aren't special enough to break the rules."
>>    BROKEN!
>>
>> "In the face of ambiguity, refuse the temptation to guess."
>>    BROKEN!
>>
>> "There should be one-- and preferably only one --obvious way to do it."
>>    BROKEN BROKEN BROKEN!
>>
>> "If the implementation is hard to explain, it's a bad idea."
>>    BROKEN!
>>
>> "If the implementation is easy to explain, it may be a good idea."
>>    REINFORCED BY BAD EXAMPLE
>>
>>
> jmf and rr in combination reminded me of this.  I hope you all get my
> drift :)
> 
> http://www.cc.gatech.edu/fac/Spencer.Rugaber/poems/love.txt

10-4, good buddy.



More information about the Python-list mailing list