On Sat, Oct 29, 2016 at 1:28 AM, Terry Reedy <[email protected]> wrote:
> If one has a translation dictionary d, use that in twice in the genexp.
>
>>>> d = {'a': '1', 'b': '3x', 'c': 'fum'}
>>>> ''.join(d[c] for c in s if c in d.keys())
> 'fum11fumfumfum1'

Trivial change:

>>> ''.join(d[c] for c in s if c in d)
'fum11fumfumfum1'

ChrisA
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to