Re: [Tutor] string replacement in Python 2 and 3

2013-11-27 Thread Albert-Jan Roskam
On Wed, 11/27/13, Steven D'Aprano wrote: Subject: Re: [Tutor] string replacement in Python 2 and 3 To: tutor@python.org Date: Wednesday, November 27, 2013, 12:36 AM On Tue, Nov 26, 2013 at 11:42:29AM -0800, Albert-Jan Roskam wrote:

Re: [Tutor] string replacement in Python 2 and 3

2013-11-26 Thread Steven D'Aprano
On Tue, Nov 26, 2013 at 11:42:29AM -0800, Albert-Jan Roskam wrote: > Hi, > > String replacement works quite differently with bytes objects in > Python 3 than with string objects in Python 2. What is the best way to > make example #1 below run in Python 2 and 3? If you are working with text str

[Tutor] string replacement in Python 2 and 3

2013-11-26 Thread Albert-Jan Roskam
Hi, String replacement works quite differently with bytes objects in Python 3 than with string objects in Python 2. What is the best way to make example #1 below run in Python 2 and 3? Should one really decode the bytes keys and (if applicable) the values to unicode? The code gets so bloated wi