Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #38823
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Subject | Re: string.replace doesn't removes ":" |
| Date | 2013-02-13 16:55 +0000 |
| References | <mailman.1536.1360407866.2939.python-list@python.org> <92122dd3-ac2e-4407-87ed-0b250ed9c8b9@googlegroups.com> <mailman.1738.1360733201.2939.python-list@python.org> <25d2297a-6fee-4ef5-bcbd-e26a28cf6ce4@e10g2000vbv.googlegroups.com> <fbca1681-2814-4331-91c1-cce852ce530d@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1746.1360774412.2939.python-list@python.org> (permalink) |
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
--
Cheers.
Mark Lawrence
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
string.replace doesn't removes ":" Joshua Robinson <shooki.robinson@gmail.com> - 2013-02-09 06:04 -0500
Re: string.replace doesn't removes ":" Johannes Bauer <dfnsonfsduifb@gmx.de> - 2013-02-10 11:36 +0100
Re: string.replace doesn't removes ":" vduncan80@gmail.com - 2013-02-12 07:14 -0800
Re: string.replace doesn't removes ":" Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-12 20:44 -0800
Re: string.replace doesn't removes ":" Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-12 21:26 -0800
Re: string.replace doesn't removes ":" Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-12 21:26 -0800
Re: string.replace doesn't removes ":" jmfauth <wxjmfauth@gmail.com> - 2013-02-12 23:10 -0800
Re: string.replace doesn't removes ":" Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-13 08:34 -0800
Re: string.replace doesn't removes ":" Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-02-13 16:55 +0000
Re: string.replace doesn't removes ":" Walter Hurry <walterhurry@lavabit.com> - 2013-02-13 18:16 +0000
Re: string.replace doesn't removes ":" 88888 Dihedral <dihedral88888@googlemail.com> - 2013-02-13 12:24 -0800
Re: string.replace doesn't removes ":" jmfauth <wxjmfauth@gmail.com> - 2013-02-14 00:02 -0800
Re: string.replace doesn't removes ":" Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-12 20:44 -0800
csiph-web